客户端范围不足 - Spotify API Golang

我想将我拥有的所有曲目放在一个新播放列表中的一个片段中,但它会抛出一个Insufficient client scope错误。这是我的代码,客户端是用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


智慧大石
浏览 159回答 1
1回答

饮歌长啸

因此,在查看 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))
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go