Python Spotify刷新令牌
问题描述:
我想获得一个刷新令牌,但我不断收到400错误。以下是我的代码。我究竟做错了什么?任何帮助,将不胜感激。谢谢。Python Spotify刷新令牌
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))
答
我的头疼得撞在墙上,但我终于明白了。我使用Spotify提供的node.js示例获取我的初始令牌和刷新令牌。发现他们的html页面有一个错误,在刷新键的末尾添加了一个额外的“>”。
这部分代码对我来说看起来很好。您是否确保在您拨打电话时使用的变量看起来正确?你有没有试过用cURL来做这件事,看看你是否可以为你的客户端ID /秘密和刷新令牌做一般的刷新工作? –
当我运行下面的curl命令时,我得到“invalid_client” curl -H“授权:基本client_id:secret_key”-d“grant_type = refresh_token”-d“refresh_token = refresh_token”“https://accounts.spotify.com/API /令牌” –