2017-10-13 77 views
1

我想獲得一個刷新令牌,但我不斷收到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)) 
+0

這部分代碼對我來說看起來很好。您是否確保在您撥打電話時使用的變量看起來正確?你有沒有試過用cURL來做這件事,看看你是否可以爲你的客戶端ID /祕密和刷新令牌做一般的刷新工作? –

+0

當我運行下面的curl命令時,我得到「invalid_client」 curl -H「授權:基本client_id:secret_key」-d「grant_type = refresh_token」-d「refresh_token = refresh_token」「https://accounts.spotify.com/API /令牌」 –

回答

1

我的頭疼得撞在牆上,但我終於明白了。我使用Spotify提供的node.js示例獲取我的初始令牌和刷新令牌。發現他們的html頁面有一個錯誤,在刷新鍵的末尾添加了一個額外的「>」。