Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/354.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 验证Spotify时出错-请求错误_Python_Localhost_Spotify - Fatal编程技术网

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