mirror of
https://github.com/jwilsson/spotify-web-api-php.git
synced 2026-04-27 07:55:49 +03:00
[GH-ISSUE #181] [Question] About refresh token #119
Labels
No labels
bug
docs
enhancement
enhancement
enhancement
feedback wanted
good first issue
help wanted
help wanted
help wanted
invalid
pull-request
question
question
upstream
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/spotify-web-api-php#119
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @foremtehan on GitHub (Jan 13, 2020).
Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/181
Am i doing it right ? I want to refresh access token when it expires, Does it refresh token for every api call ? :
@jwilsson commented on GitHub (Jan 13, 2020):
Hey!
Yes, that code will refresh the access token automatically when it detects an expired one.
Some parts of your code isn't needed though and I recommend you to store the (possibly new) access and refresh tokens somewhere (like a database or session). I'd rewrite it like this:
Hope this helps!
@foremtehan commented on GitHub (Jan 13, 2020):
@jwilsson thanks! But i dont understand this part :
if ($oldAccessToken && $oldRefreshToken)If i store this old tokens somewhere else the if condition always be true, Should i (how) check the tokens expiration before condition?@jwilsson commented on GitHub (Jan 13, 2020):
@foremtehan No, you don't need to check the expiration. It'll refresh them if needed. You can skip the
ifstatement if you're sure you'll always have something stored (they're not being null).