jwilsson / spotify-web-api-php

A PHP wrapper for Spotify's Web API.
MIT License
868 stars 156 forks source link

Auto-Refreshing access token. #252

Closed scoder21 closed 2 years ago

scoder21 commented 2 years ago

Hey @jwilsson!

I have some questions about the auto-refreshing access token system.

  1. When using it, does it replace the "callback.php" file or is that a different one? The flow I'm talking about: https://github.com/jwilsson/spotify-web-api-php/blob/main/docs/examples/access-token-with-authorization-code-flow.md

  2. When using it, do you need to keep track of the time or redirect the user manually or is it really all done "automatically"?

I hope to hear from you soon.

Kind Regards

jwilsson commented 2 years ago

Hey! You still need callback.php for the initial access token request. But afterwards the user won't be redirected anymore, the refresh token returned from Spotify will be used to automatically request new access tokens in the background when the previous access token has expired. You will need to keep track of the refresh token so it can be used to request a new access token. And be sure to grab the refresh token from your Session instance after each call since it might have requested new tokens and given you a new one (the docs linked below has some examples).

There's some more docs specifically on refreshing access tokens, but do let me know if you have any other questions.

scoder21 commented 2 years ago

Okay, if I have other questions, I will get back to you. Thanks for the quick response!