【发布时间】:2021-01-08 06:19:10
【问题描述】:
我正在尝试使用来自Spotipy docs 的代码来查看客户端授权代码流的工作原理。起初它有效,但过了一段时间我收到此错误:无法刷新令牌。响应状态代码:400 原因:错误请求。除了将客户端凭据添加到代码中之外,我根本没有编辑文档中的代码。谢谢! 这是我的代码:
import spotipy
from spotipy.oauth2 import SpotifyOAuth
scope = "user-library-read"
client_id='xxxxxxx'
client_secret='xxxxxx'
redirect_uri = "http://localhost:5000/callback"
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=scope,client_id=client_id,client_secret=client_secret,redirect_uri=redirect_uri))
results = sp.current_user_saved_tracks()
for idx, item in enumerate(results['items']):
track = item['track']
print(idx, track['artists'][0]['name'], " – ", track['name'])
【问题讨论】: