init auth func

This commit is contained in:
2025-11-23 21:33:21 +00:00
parent e705d175cb
commit fbd3bba63f

View File

@@ -1,9 +1,31 @@
package services package services
import ( import (
"github.com/zmb3/spotify/v2" "fmt"
spotifyauth "github.com/zmb3/spotify/v2/auth"
) )
func InitSpotify() *spotify.Client { type SpotifyConfig struct {
return nil AuthState string
RedirectURL string
ClientID string
ClientSecret string
}
func InitSpotifyAuth(config SpotifyConfig) *spotifyauth.Authenticator {
auth := spotifyauth.New(
spotifyauth.WithRedirectURL(config.RedirectURL),
spotifyauth.WithClientID(config.ClientID),
spotifyauth.WithClientSecret(config.ClientSecret),
spotifyauth.WithScopes(
spotifyauth.ScopeUserReadPlaybackState,
spotifyauth.ScopeUserReadCurrentlyPlaying,
),
)
fmt.Println("Authenticate spotify with:")
fmt.Println(auth.AuthURL(config.AuthState))
return auth
} }