login5

package
v0.0.0-...-4c80b8c Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Login5

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

Login5 manages authentication against the Spotify Login5 endpoint (https://login5.spotify.com/v3/login). It handles challenge solving (hashcash), stores the resulting access token, and provides automatic token renewal via the AccessToken function.

Login5 is safe for concurrent use.

func NewLogin5

func NewLogin5(log spotcontrol.Logger, client *http.Client, deviceId, clientToken string) *Login5

NewLogin5 creates a new Login5 client. The deviceId and clientToken are required for constructing LoginRequest messages. If client is nil a default HTTP client with a 30-second timeout is used.

func (*Login5) AccessToken

func (c *Login5) AccessToken() spotcontrol.GetLogin5TokenFunc

AccessToken returns a GetLogin5TokenFunc that retrieves (and automatically renews) the Login5 access token. The returned function is safe for concurrent use.

When force is true, a fresh token is always obtained by re-authenticating with the stored credentials. When force is false, the cached token is returned if it has not yet expired.

func (*Login5) Login

func (c *Login5) Login(ctx context.Context, credentials proto.Message) error

Login authenticates with the Login5 endpoint using the given credentials protobuf. Supported credential types are StoredCredential, FacebookAccessToken, OneTimeToken, ParentChildCredential, AppleSignInCredential, SamsungSignInCredential, and GoogleSignInCredential.

If the server responds with challenges (e.g. hashcash), they are solved automatically and the request is retried with the solutions.

func (*Login5) StoredCredential

func (c *Login5) StoredCredential() []byte

StoredCredential returns the stored credential bytes from the most recent successful Login5 authentication. These can be used to re-authenticate without the original password. It panics if Login has not been called successfully.

func (*Login5) Username

func (c *Login5) Username() string

Username returns the canonical username from the most recent successful Login5 authentication. It panics if Login has not been called successfully.

type LoginError

type LoginError struct {
	Code pb.LoginError
}

LoginError is returned when the Login5 endpoint returns an error code instead of a successful authentication response.

func (*LoginError) Error

func (e *LoginError) Error() string

Jump to

Keyboard shortcuts

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