验证 Spotify 时出错 - 错误请求
Error Authenticating Spotify - Bad Request
我很难在 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
有什么问题吗?
你试过没有端口号吗?
所以替换
localhost:8888/callback
有了这个:
localhost:/callback
我很难在 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
有什么问题吗?
你试过没有端口号吗? 所以替换
localhost:8888/callback
有了这个:
localhost:/callback