您可以通过 curl 获取刷新令牌
curl -d client_id={CLIENT_ID}
-d client_secret={CLIENT_SECRET}
-d grant_type=authorization_code
-d code={CODE}
-d redirect_uri={REDIRECT_URI}
https://accounts.spotify.com/api/token
第 1 步 - 创建您的应用程序
在Spotify Developer Dashboard 中创建您的应用程序
获取Client ID、Client Secret并添加redirect URIs
第 2 步 - 获取代码
https://accounts.spotify.com/authorize?response_type=code&client_id={your client id}&scope=user-read-email&redirect_uri={your redirect URL, mine is http://localhost:3000}
浏览器会在地址控件中显示代码,复制code部分。
第 3 步 - 获取刷新
从终端通过 curl 获取刷新代码
curl -d client_id={your client it}
-d client_secret={your client secret}
-d grant_type=authorization_code
-d code={code from Step #2}
-d redirect_uri=http://localhost:3000
https://accounts.spotify.com/api/token | jq
您可以获得刷新令牌
{
"access_token": "BQC...V-1"
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "AQA...6twR
"scope": "user-read-email"
}
参考
How to create a Spotify refresh token the easy way