卓越飞翔博客卓越飞翔博客

卓越飞翔 - 您值得收藏的技术分享站
技术文章34157本站已运行391

客户端范围不足 - Spotify API Golang

客户端范围不足 - 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))
卓越飞翔博客
上一篇: 如何让两个以上的命令行标志控制相同的行为?
下一篇: 返回列表
留言与评论(共有 0 条评论)
   
验证码:
隐藏边栏