为了账号安全,请及时绑定邮箱和手机立即绑定

客户端范围不足 - Spotify API Golang

客户端范围不足 - Spotify API Golang

Go
智慧大石 2023-03-15 15:36:20
我想将我拥有的所有曲目放在一个新播放列表中的一个片段中,但它会抛出一个Insufficient client scope错误。这是我的代码,客户端是用authfunc 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
查看完整描述

1 回答

?
饮歌长啸

TA贡献1951条经验 获得超3个赞

因此,在查看 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))



查看完整回答
反对 回复 2023-03-15
  • 1 回答
  • 0 关注
  • 158 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号