session

package
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2026 License: GPL-3.0 Imports: 26 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewOAuth2Server

func NewOAuth2Server(ctx context.Context, log librespot.Logger, callbackPort int) (int, chan string, error)

Types

type BlobCredentials

type BlobCredentials struct {
	Username string
	Blob     []byte
}

type DeviceAuthCode added in v0.9.1

type DeviceAuthCode struct {
	// VerificationUrl is where the user approves the request. It usually
	// already embeds UserCode.
	VerificationUrl string
	// UserCode is the code to enter at VerificationUrl, if prompted.
	UserCode string
	// ExpiresAt is when the code stops being accepted.
	ExpiresAt time.Time
}

DeviceAuthCode is the pairing code of a device authorization flow waiting for the user to approve it.

type DeviceAuthCredentials added in v0.9.1

type DeviceAuthCredentials struct {
	// OnCode, if set, is called with the pairing code as soon as Spotify
	// issues it and with nil once it is no longer usable, so the code can be
	// shown somewhere other than the log while the flow waits for the user.
	OnCode func(*DeviceAuthCode)
}

DeviceAuthCredentials authenticates with the OAuth 2.0 device authorization flow: Spotify issues a code that the user enters on another device. Nothing listens on a port and no browser is needed on this machine.

type InteractiveCredentials

type InteractiveCredentials struct {
	CallbackPort int
}

type Options

type Options struct {
	// Log is the base logger entry to use.
	Log librespot.Logger

	// DeviceType is the Spotify showed device type, required.
	DeviceType devicespb.DeviceType
	// DeviceId is the Spotify device ID, required.
	DeviceId string
	// Credentials is the credentials to be used for authentication, required.
	Credentials any

	// ClientToken is the Spotify client token, leave empty to let the server generate one.
	ClientToken string
	// Resolver is an instance of apresolve.ApResolver, leave nil to use the default one.
	Resolver *apresolve.ApResolver
	// PreferFirewallFriendlyPorts prefers accesspoints on 443 and 80 over the
	// default 4070. Only consulted when Resolver is nil, since a supplied
	// resolver already carries its own preference.
	PreferFirewallFriendlyPorts bool

	// Client is the HTTP client to use for the session, leave empty for a new one.
	Client *http.Client

	// StateStore is the state store to use for the session.
	StateStore librespot.StateStore
}

type Session

type Session struct {
	// contains filtered or unexported fields
}

func NewSessionFromOptions

func NewSessionFromOptions(ctx context.Context, opts *Options) (*Session, error)

func (*Session) Accesspoint

func (s *Session) Accesspoint() *ap.Accesspoint

func (*Session) AudioKey

func (s *Session) AudioKey() *audio.KeyProvider

func (*Session) Close

func (s *Session) Close()

func (*Session) Dealer

func (s *Session) Dealer() *dealer.Dealer

func (*Session) Events added in v0.3.0

func (s *Session) Events() player.EventManager

func (*Session) Mercury added in v0.3.0

func (s *Session) Mercury() *mercury.Client

func (*Session) Spclient

func (s *Session) Spclient() *spclient.Spclient

func (*Session) StoredCredentials

func (s *Session) StoredCredentials() []byte

func (*Session) Username

func (s *Session) Username() string

type SpotifyTokenCredentials

type SpotifyTokenCredentials struct {
	Username string
	Token    string
}

type StoredCredentials

type StoredCredentials struct {
	Username string
	Data     []byte
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL