How Can I increase the expiry time of Spotify token?

北慕城南 提交于 2019-12-23 08:53:51

问题


Please advice how can I increase token expiry time While fetching data using spotify web API "https://accounts.spotify.com/api/token"


回答1:


Access tokens expire after one hour. This expiry time is set on Spotify's side and can't be changed by the client.

You can refresh an access token if you're retrieving it using the Authorization Code flow. (The refresh token is practically valid forever, or until it has been manually revoked.)




回答2:


As stated by Michael Thelin, the token's expiration time is determined by Spotify so you just have to work around their set constraints.

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.

After that hour is up, use your refresh_token to request a new token.



来源:https://stackoverflow.com/questions/30372835/how-can-i-increase-the-expiry-time-of-spotify-token

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!