Please advice how can I increase token expiry time While fetching data using spotify web API "https://accounts.spotify.com/api/token"
-
Welcome to SO. Can you please provide a code snippet that is accessing the API? Are you having an issue with the token expiring or a request timing out? – kaz May 21 '15 at 12:14
2 Answers
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.)

- 4,710
- 3
- 23
- 29
-
Steve, you can consider it to be valid forever. I've updated my response. – Michael Thelin Jan 28 '16 at 15:38
-
2@MichaelThelin what's your source on the length of validity of the refresh token? I couldn't find any document on how long your refresh token is valid for. How does it get revoked? – NinjaCowgirl Apr 13 '17 at 19:38
-
6@NinjaCowgirl, That information isn't available on the Developer site, but it should be. I'll forward that to the relevant team. A token can be revoked by the user from the user's account page on spotify.com. – Michael Thelin Apr 15 '17 at 07:22
-
I'm not sure when [this article](https://developer.spotify.com/documentation/ios/guides/token-swap-and-refresh/) was posted on Spotify, but yes the lifetime of the token is one hour – Simple Sandman Nov 25 '19 at 01:12
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.

- 121
- 1
- 4