首頁  >  文章  >  後端開發  >  客戶端範圍不足 - Spotify API Golang

客戶端範圍不足 - Spotify API Golang

PHPz
PHPz轉載
2024-02-06 10:03:07860瀏覽

客户端范围不足 - 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刪除