Spotify API Golang中的客户端范围不足
时间:2024-03-03
浏览:390
作者:佚名
目前golang学习网上已经有很多关于Golang的文章了,自己在初次阅读这些文章中,也见识到了很多学习思路;那么本文《Spotify API Golang中的客户端范围不足》,也希望能帮助到大家,如果阅读完后真的对你学习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中的客户端范围不足》的详细介绍,大家都掌握了吧!如果想要继续提升自己的能力,那么就来关注golang学习网公众号吧!
本文内容来源于互联网,如有侵权请联系删除。
近期热门
11.18
11.15
站内热门
最新文章
11.28
11.28
11.28
热门专题
