diff --git a/backend/services/spotify.go b/backend/services/spotify.go index aca12b8..b6cef1f 100644 --- a/backend/services/spotify.go +++ b/backend/services/spotify.go @@ -1,9 +1,31 @@ package services import ( - "github.com/zmb3/spotify/v2" + "fmt" + + spotifyauth "github.com/zmb3/spotify/v2/auth" ) -func InitSpotify() *spotify.Client { - return nil +type SpotifyConfig struct { + 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 }