【发布时间】:2016-05-18 16:11:10
【问题描述】:
我很难在localhost 上验证我的spotify 应用程序。我在我的开发者帐户中将redirect_uri 设置为localhost:8888/callback(也尝试使用http://),但是当终端提示我输入要重定向到的URL 时,我收到此错误页面。
我正在使用python -m SimpleHTTPServer 8888 运行我的服务器,并在终端python script.py username 输入。
这是我的 Python 脚本:
scope = 'user-library-read'
if len(sys.argv) > 1:
username = sys.argv[1]
else:
print "Usage: %s username" % (sys.argv[0],)
sys.exit()
token = util.prompt_for_user_token(username, scope, client_id='myId', client_secret='mySecret', redirect_uri='localhost:8888/callback')
if token:
sp = spotipy.Spotify(auth=token)
results = sp.current_user_saved_tracks()
for item in results['items']:
track = item['track']
print track['name'] + ' - ' + track['artists'][0]['name']
else:
print "Can't get token for", username
这是日志:
token_info = sp_oauth.get_access_token(code)
File "/Library/Python/2.7/site-packages/spotipy/oauth2.py", line 210, in get_access_token
raise SpotifyOauthError(response.reason)
spotipy.oauth2.SpotifyOauthError: Bad Request
可能出了什么问题?
【问题讨论】: