首页 > 后端开发 > Golang > 正文

客户端范围不足 - Spotify API Golang

PHPz
发布: 2024-02-06 10:03:07
转载
843 人浏览过

客户端范围不足 - 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
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!