Maison  >  Article  >  développement back-end  >  Portée client insuffisante - Spotify API Golang

Portée client insuffisante - Spotify API Golang

PHPz
PHPzavant
2024-02-06 10:03:07856parcourir

客户端范围不足 - Spotify API Golang

Contenu de la question

Je souhaite mettre tous les morceaux du slice dans une nouvelle playlist mais ça me déstabilise insufficient clientscope 错误。这是我的代码,客户端是使用 auth Créé

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...)
}

J'ai vu une solution possible en python ici mais je ne sais pas comment la convertir en API Go via zmb3


Réponse correcte


Donc, après avoir regardé plus de code dans github, j'ai trouvé le problème à partir de la déclaration auth, Je n'ai pas ajouté la portée nécessaire. Cela devrait ressembler à ceci :

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))

Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!

Déclaration:
Cet article est reproduit dans:. en cas de violation, veuillez contacter admin@php.cn Supprimer