python - Spotify Web API 经常给出 500 错误

标签 python django spotify python-requests

我正在构建一个应用程序,该应用程序使用 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/

相关文章:

python - 当列表为空时列表理解抛出异常

django - 使用 celery 和 django 实现硬超时

python - 使用 Python 进行 Spotify API 身份验证

django - Rietveld 是否与 App Engine 密不可分?

c# - 如何使用 Spotify API 将艺术家的名字添加到端点?

python - Spotify API 在尝试获取播客信息时返回 404 not found

python - 通过更改和导入模块在 Python 中传递 "local"变量?

python - 计算pandas数据框中满足特定总和条件的行数

python - 在程序关闭期间在 Python 中捕获 KeyboardInterrupt

python - 在 django 代码中实现谷歌地图