Python 验证Spotify时出错-请求错误
我很难在Python 验证Spotify时出错-请求错误,python,localhost,spotify,Python,Localhost,Spotify,我很难在localhost上验证我的spotify应用程序。我在我的开发者帐户中将我的redirect\u uri设置为localhost:8888/callback(也尝试了http://),但当终端提示我输入重定向到的URL时,我会看到这个错误页面 我正在使用python-msimplehttpserver 8888运行我的服务器,并在终端pythonscript.py用户名中输入 这是我的Python脚本: scope = 'user-library-read' if len(sys.a
localhost
上验证我的spotify
应用程序。我在我的开发者帐户中将我的redirect\u uri
设置为localhost:8888/callback
(也尝试了http://
),但当终端提示我输入重定向到的URL时,我会看到这个错误页面
我正在使用python-msimplehttpserver 8888运行我的服务器,并在终端pythonscript.py用户名中输入
这是我的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:8888/callback
为此:
localhost:/callback
它起作用了,但我们必须将localhost:/callback
更改为127.0.0.1/callback
它起作用了,但我们必须将localhost:/callback
更改为127.0.0.1/callback