【发布时间】:2014-08-19 16:07:46
【问题描述】:
我正在构建一个使用 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 密钥信息)
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)
用户通过身份验证后,重定向到如下视图:
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 django spotify python-requests