Announcements

Spotify API PKCE Refresh Token Process

Solved!

Spotify API PKCE Refresh Token Process

jessewolven

Hello,

 

I've created authorization code flow with PKCE in JavaScript for my personal website to access top tracks and artists from the user and display them on the page. My issue right now is that I'm new to API's and I'm not sure how to use the refresh token. 

 

So, the concept is that after you get the access token, you get an expiration time, and a refresh token. I use the access token to get the top tracks and artists. But I'm unsure of the process after that. You wait for the 3600 seconds, then you send the POST request with the refresh token. Then what? Do I have to do anything with the new access token? Do I infinitely use the refresh token to get new access tokens? And when I get the new access token, do I have to re-request the top tracks and artists?

 

Hopefully that's understandable,

Thanks!

Reply

Accepted Solutions
Marked as solution

bstrauch24

I think you have the right idea; if you've already authenticated and you want to make a request, but you realize that your access token is expired, you have to send your refresh token to the refresh endpoint, where you get a new access token and refresh token. After you've done that you can make a request as you normally would.

 

The key thing to realize is that you should have some code that checks your token's expiration before every request you send.

View solution in original post

2 Replies
Marked as solution

bstrauch24

I think you have the right idea; if you've already authenticated and you want to make a request, but you realize that your access token is expired, you have to send your refresh token to the refresh endpoint, where you get a new access token and refresh token. After you've done that you can make a request as you normally would.

 

The key thing to realize is that you should have some code that checks your token's expiration before every request you send.

AmitVaidya

please help me! I know how this process work but can't find refresh token endpoint to refresh my access token

Suggested posts

Env: prod