Home > database >  Insufficient client scope - Spotify API Golang
Insufficient client scope - Spotify API Golang

Time:11-22

I want to put all the tracks that i have in a slice inside a new playlist but it throws me a Insufficient client scope error. This is my code and the client is created with auth

func copyTracksToPlaylist(filteredTracks []spotify.PlaylistItem, client *spotify.Client, ctx context.Context) error {
   newPlaylistID := os.Getenv("NEW_PLAYLIST_ID")

   filteredSongsIDs := extractTracksIDs(filteredTracks)

   return client.ReplacePlaylistTracks(ctx, spotify.ID(newPlaylistID), filteredSongsIDs...)
}

I have seen the posible solution in Python here but i don't know how to translate this to the Go's API by zmb3

CodePudding user response:

So after looking at more code in GitHub i found out that the problem was in the declaration of the auth that i didn't add the neccesaries scopes. It should look something like this:

auth = spotifyauth.New(spotifyauth.WithClientID(os.Getenv("SPOTIFY_ID")), spotifyauth.WithClientSecret(os.Getenv("SPOTIFY_SECRET")), spotifyauth.WithRedirectURL(RedirectUrl), spotifyauth.WithScopes(spotifyauth.ScopeUserReadPrivate, spotifyauth.ScopePlaylistModifyPublic, spotifyauth.ScopePlaylistModifyPrivate, spotifyauth.ScopeUserLibraryRead, spotifyauth.ScopeUserLibraryModify))
  • Related