spotifyapi

package module
v0.0.0-...-c41edc2 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2021 License: MIT Imports: 7 Imported by: 0

README

spotify-oauth-proxy

Managed OAuth access for your spotify account

WARNING

This project is unmaintained. Please go to https://github.com/conradludgate/oauth2-proxy for the newer project

How it works

  1. Go to https://spotify.conradludgate.com/login
  2. Choose the scopes you wish to use.
  3. Click confirm and login with your Spotify account
  4. Copy and save the API Key. You will only see it once and it's needed to access the API

And you're all set. Now you can make a request to

GET https://spotify.conradludgate.com/api/token
Authorization: Basic <base64 encoded user_id:api_key>

And it will respond with your account's access token, token type and expiry time.

{"access_token": "XXXXX", "token_type": "Bearer", "expires": 1610115227}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	UserID string
	APIKey string
	// contains filtered or unexported fields
}

func (*API) Authenticate

func (api *API) Authenticate(r *http.Request) error

func (*API) GetToken

func (api *API) GetToken() (*Token, error)

func (*API) RoundTrip

func (api *API) RoundTrip(r *http.Request) (*http.Response, error)

func (*API) WithContext

func (api *API) WithContext(ctx context.Context) *API

func (*API) WithHTTPTransport

func (api *API) WithHTTPTransport(rt http.RoundTripper) *API

func (*API) WithURL

func (api *API) WithURL(url string) *API

type Token

type Token struct {
	AccessToken string    `json:"access_token"`
	TokenType   string    `json:"token_type"`
	Expiry      time.Time `json:"expiry"`
}

func (*Token) IsValid

func (t *Token) IsValid() bool

IsValid reports whether t is non-nil, has an AccessToken, and is not expired.

func (*Token) SetAuthHeader

func (t *Token) SetAuthHeader(r *http.Request)

func (*Token) Type

func (t *Token) Type() string

Type returns t.TokenType if non-empty, else "Bearer".

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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