From fbd3bba63fb9da706fbafa0b1fdac3252006640f Mon Sep 17 00:00:00 2001 From: Adam French Date: Sun, 23 Nov 2025 21:33:21 +0000 Subject: [PATCH] init auth func --- backend/services/spotify.go | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) 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 }