diff --git a/backend/main.go b/backend/main.go index ca0d755..fe886f2 100644 --- a/backend/main.go +++ b/backend/main.go @@ -9,8 +9,6 @@ import ( "adam-french.co.uk/backend/handlers" "adam-french.co.uk/backend/services" - - spotifyauth "github.com/zmb3/spotify/v2/auth" ) func main() { @@ -35,21 +33,11 @@ func main() { redirectURL := os.Getenv("SPOTIFY_REDIRECT_URI") clientID := os.Getenv("SPOTIFY_CLIENT_ID") clientSecret := os.Getenv("SPOTIFY_CLIENT_SECRET") + spotifyConfig := services.SpotifyConfig{AuthState: authState, RedirectURL: redirectURL, ClientID: clientID, ClientSecret: clientSecret} - auth := spotifyauth.New( - spotifyauth.WithRedirectURL(redirectURL), - spotifyauth.WithClientID(clientID), - spotifyauth.WithClientSecret(clientSecret), - spotifyauth.WithScopes( - spotifyauth.ScopeUserReadPlaybackState, - spotifyauth.ScopeUserReadCurrentlyPlaying, - ), - ) + auth := services.InitSpotifyAuth(spotifyConfig) - fmt.Println("Authenticate spotify with:") - fmt.Println(auth.AuthURL(authState)) - - store := handlers.Store{DB: db, SpotifyAuth: auth, SpotifyToken: nil} + store := handlers.Store{DB: db, SpotifyAuth: auth, SpotifyClient: nil} r.GET("/posts", store.GetPosts) r.POST("/posts", store.CreatePost)