更新时间:2022-06-27 07:06:16
之前有效而现在无效的原因是 access token
过期.
The reason why it worked before and not now is due to the expiration of the access token
.
令牌的到期时间由 Spotify 确定,因此您只需解决其设置的限制.
The token's expiration time is determined by Spotify so you just have to work around their set constraints.
话虽如此,您可以根据属性 expires_in
预测何时需要生成/使用新令牌,当您请求令牌时,Spotify 在响应中发回该属性 (https://accounts.spotify.com/api/token
).expires_in
属性是一个整数,它告诉您令牌可以使用多少秒.如他们的授权文档所示,expires_in
属性返回值为 3600(秒)或 1 小时.
That being said, you can anticipate when a new token will need to be generated/used based on the property expires_in
which Spotify sends back in the response when you request a token (https://accounts.spotify.com/api/token
). The expires_in
property is an integer and it tells you how many seconds the token will be good for. As seen in their authorization documentation, the expires_in
property is returned with the value 3600 (seconds) or, 1 hour.
在那一小时结束后,使用您的refresh_token
请求一个新令牌.
After that hour is up, use your refresh_token
to request a new token.