【问题标题】:Error Authenticating Spotify - Bad Request验证 Spotify 时出错 - 错误请求
【发布时间】: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

可能出了什么问题?

【问题讨论】:

    标签: python localhost spotify


    【解决方案1】:

    你试过没有端口号吗? 所以替换

    localhost:8888/callback
    

    用这个:

    localhost:/callback
    

    【讨论】:

    • 它有效,但我们必须将localhost:/callback 更改为127.0.0.1/callback
    猜你喜欢
    • 1970-01-01
    • 2012-04-22
    • 2022-01-10
    • 2018-04-19
    • 2017-07-16
    • 1970-01-01
    • 2018-06-07
    • 2020-07-24
    • 2014-10-25
    相关资源
    最近更新 更多