MCPcopy Create free account
hub / github.com/dinofizz/diskplayer / NewAuthenticator

Function NewAuthenticator

auth.go:16–32  ·  view source on GitHub ↗

NewAuthenticator returns a Spotify authenticator object configured with the required callback URL, client IT and client secret. An error is returned if one is encountered

()

Source from the content-addressed store, hash-verified

14// NewAuthenticator returns a Spotify authenticator object configured with the required callback URL,
15// client IT and client secret. An error is returned if one is encountered
16func NewAuthenticator() (*spotify.Authenticator, error) {
17 r := ConfigValue(SPOTIFY_CALLBACK_URL)
18 u, err := url.Parse(r)
19 if err != nil {
20 return nil, err
21 }
22
23 id := ConfigValue(SPOTIFY_CLIENT_ID)
24 s := ConfigValue(SPOTIFY_CLIENT_SECRET)
25
26 auth := spotify.NewAuthenticator(u.String(), spotify.ScopeUserReadPrivate, spotify.ScopePlaylistReadPrivate,
27 spotify.ScopeUserModifyPlaybackState, spotify.ScopeUserReadPlaybackState)
28
29 auth.SetAuthInfo(id, s)
30
31 return &auth, nil
32}
33
34// NewToken will create a new OAuth2 token request.
35// The user will be prompted to visit a URL, and after access is granted a new OAuth2 token is returned.

Callers 5

mainFunction · 0.92
TestNewAuthenticatorFunction · 0.85
TestNewTokenFunction · 0.85

Calls 1

ConfigValueFunction · 0.85

Tested by 4

TestNewAuthenticatorFunction · 0.68
TestNewTokenFunction · 0.68