我正在构建一个应用程序,该应用程序使用 python 包“spotipy”与 Spotify Web API 交互。
但是,我会随机收到 500 个错误,如下所示:
http status: 500, code:-1 - the requested resource could not be found: https://api.spotify.com/v1/users/[USERNAME]/playlists
这是我的工作流程(减去我的 api key 信息)
client_id = ''
client_secret = ''
redirect_uri = 'http://127.0.0.1:8000/spotify/'
scope = 'playlist-read-private user-read-private playlist-modify-private'
auth = oauth2.SpotifyOAuth(client_id, client_secret, redirect_uri, scope = scope)
def spotify_auth(request):
auth_url = auth.get_authorize_url()
return HttpResponseRedirect(auth_url)
用户通过身份验证后,将被重定向到以下 View :
def spotify(request):
token_code = request.GET.get('code')
token = auth.get_access_token(token_code)
sp = spotipy.Spotify(auth=token['access_token'])
user = sp.me()
playlists = sp.user_playlists(user['id'])
此时,我会经常(但并非总是)收到 500 错误...
最佳答案
用于获取用户播放列表的端点昨天有点无聊,但今天似乎工作正常。我会再试一次。
关于python - Spotify Web API 经常给出 500 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25388122/