Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spotify check if access_token is expired

A small questions. At the moment i'm using Spotify Webapi, and I want to know is there a Web API Endpoint to check if an access_token is expired? At the moment I'm using

GET https://api.spotify.com/v1/me

to check if an access_token is expired.

like image 947
shaw kwok Avatar asked Dec 05 '14 20:12

shaw kwok


People also ask

How do I know if my access token is expired?

You can confirm your expiration date anytime by going to Settings > WorkSpace Settings > Social Accounts. Then simply look under the Token Status to learn the expiration date of your accounts token. (This means ContentStudio has access to your social networks for 39 days.

How long is Spotify access token valid?

Access tokens issued from the Spotify account service has a lifetime of one hour. If a longer session is desired Spotify account service supports the OAuth Code grant flow.

Do API tokens expire?

Tokens are valid for 30 days from creation or last use, so that the 30 day expiration automatically refreshes with each API call. Tokens that aren't used for 30 days expire. The 30-day period is currently fixed and can't be changed for your organization.


1 Answers

There's no endpoint to check how long time there's left until a token expires, but you can use the response to the access token request to find out.

As explained in the Web API Authorization Guide, the response including the access token also contains

expires_in   int    The time period (in seconds) for which the access token is valid. 
like image 109
Michael Thelin Avatar answered Sep 18 '22 06:09

Michael Thelin