首页  >  文章  >  后端开发  >  客户端范围不足 - Spotify API Golang

客户端范围不足 - Spotify API Golang

PHPz
PHPz转载
2024-02-06 10:03:07856浏览

客户端范围不足 - Spotify API Golang

问题内容

我想将切片中的所有曲目放入新的播放列表中,但它向我抛出 insufficient clientscope 错误。这是我的代码,客户端是使用 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...)
}

我在这里看到了python中可能的解决方案,但我不知道如何通过zmb3将其转换为go的api


正确答案


因此,在查看 github 中的更多代码后,我发现问题出在 auth 的声明中,我没有添加必要的范围。它应该看起来像这样:

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

以上是客户端范围不足 - Spotify API Golang的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文转载于:stackoverflow.com。如有侵权,请联系admin@php.cn删除