【问题标题】:Python Spotify Refresh TokenPython Spotify 刷新令牌
【发布时间】:2017-10-13 13:22:18
【问题描述】:

我正在尝试获取刷新令牌,但我不断收到 400 错误。下面是我的代码。我究竟做错了什么?任何帮助,将不胜感激。谢谢。

clientid="xxx"
refreshkey="xxx"
secretkey="xxx"
spotifyurl="https://accounts.spotify.com/api/token"
spotifydata = {'grant_type': 'refresh_token', 'refresh_token':refreshkey}
response = requests.post(spotifyurl, data=spotifydata, auth=(clientid, secretkey))

【问题讨论】:

  • 这部分代码对我来说看起来不错。您是否确保在拨打电话时使用的变量看起来正确?您是否尝试过使用 cURL 执行此操作,以查看是否可以为您拥有的客户端 id/secret 和刷新令牌进行一般刷新?
  • 当我运行以下 curl 命令时,我得到“invalid_client” curl -H "Authorization: Basic client_id:secret_key" -d "grant_type=refresh_token" -d "refresh_token=refresh_token" "accounts.spotify.com/api/token"

标签: python spotify


【解决方案1】:

我的头因为撞到墙上而疼,但我终于想通了。我正在使用 Spotify 提供的 node.js 示例来获取我的初始令牌和刷新令牌。原来他们的 html 页面有一个错误,在刷新键的末尾添加了一个额外的“>”。

【讨论】:

    猜你喜欢
    • 2021-07-19
    • 2021-10-11
    • 1970-01-01
    • 1970-01-01
    • 2018-02-21
    • 2017-06-26
    • 1970-01-01
    • 2022-07-15
    • 2023-02-02
    相关资源
    最近更新 更多