Documentation ¶
Index ¶
- Constants
- type Auth
- type Login
- type MockedAuth
- type MockedResponseWriter
- type MockedSpotifyauthAuthenticator
- func (a MockedSpotifyauthAuthenticator) AuthURL(_ string, _ ...oauth2.AuthCodeOption) string
- func (a MockedSpotifyauthAuthenticator) Client(_ context.Context, _ *oauth2.Token) *http.Client
- func (a MockedSpotifyauthAuthenticator) Exchange(_ context.Context, _ string, _ ...oauth2.AuthCodeOption) (*oauth2.Token, error)
- func (a MockedSpotifyauthAuthenticator) Token(_ context.Context, _ string, _ *http.Request, _ ...oauth2.AuthCodeOption) (*oauth2.Token, error)
- type SpotifyAuthenticatior
Constants ¶
const (
// TokenFileName is the standard file name to save the OAuth token to
TokenFileName = "token.json"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Auth ¶
Auth is the interface Login implements. It supports log in to the Spotify account. You can also save the token to a file.
type Login ¶
type Login struct {
// contains filtered or unexported fields
}
Login is the type to use when logging into a Spotify account.
func NewLogin ¶
NewLogin creates a new Login with the given callbackURL to listen on. It will also create a code verifier for this login.
type MockedAuth ¶
MockedAuth implements the Auth interface for tests.
func (MockedAuth) Login ¶
func (l MockedAuth) Login() *oauth2.Token
Login will return a token or error.
type MockedResponseWriter ¶
type MockedResponseWriter struct {
// contains filtered or unexported fields
}
MockedResponseWriter implements http.ResponseWriter for tests
func (*MockedResponseWriter) Header ¶
func (w *MockedResponseWriter) Header() http.Header
Header returns the HTTP header
func (*MockedResponseWriter) Write ¶
func (w *MockedResponseWriter) Write(b []byte) (int, error)
Write writes some bytes to the body
func (*MockedResponseWriter) WriteHeader ¶
func (w *MockedResponseWriter) WriteHeader(statusCode int)
WriteHeader sets the status code
type MockedSpotifyauthAuthenticator ¶
type MockedSpotifyauthAuthenticator struct {
FailToken bool
}
MockedSpotifyauthAuthenticator implements interface SpotifyAuthenticatior for tests
func (MockedSpotifyauthAuthenticator) AuthURL ¶
func (a MockedSpotifyauthAuthenticator) AuthURL(_ string, _ ...oauth2.AuthCodeOption) string
AuthURL returns a URL to the the Spotify Accounts Service's OAuth2 endpoint.
func (MockedSpotifyauthAuthenticator) Client ¶
Client creates a *http.Client that will use the specified access token for its API requests. Combine this with spotify.HTTPClientOpt.
func (MockedSpotifyauthAuthenticator) Exchange ¶
func (a MockedSpotifyauthAuthenticator) Exchange(_ context.Context, _ string, _ ...oauth2.AuthCodeOption) (*oauth2.Token, error)
Exchange is like Token, except it allows you to manually specify the access code instead of pulling it out of an HTTP request.
func (MockedSpotifyauthAuthenticator) Token ¶
func (a MockedSpotifyauthAuthenticator) Token(_ context.Context, _ string, _ *http.Request, _ ...oauth2.AuthCodeOption) (*oauth2.Token, error)
Token pulls an authorization code from an HTTP request and attempts to exchange it for an access token. The standard use case is to call Token from the handler that handles requests to your application's redirect URL.
type SpotifyAuthenticatior ¶
type SpotifyAuthenticatior interface { AuthURL(state string, opts ...oauth2.AuthCodeOption) string Token(ctx context.Context, state string, r *http.Request, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error) Exchange(ctx context.Context, code string, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error) Client(ctx context.Context, token *oauth2.Token) *http.Client }
SpotifyAuthenticatior is an interface for spotifyauth.Authenticator