[PR #126] [MERGED] Better support for refresh tokens #262

Closed
opened 2026-02-27 19:26:51 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/jwilsson/spotify-web-api-php/pull/126
Author: @shivampaw
Created: 5/31/2018
Status: Merged
Merged: 6/3/2018
Merged by: @jwilsson

Base: masterHead: master


📝 Commits (2)

  • efae404 Allow the refresh token to be set - useful when automating a refresh
  • ef666f1 When refreshing token, if one isn't set in the class then set it to the one passed through

📊 Changes

1 file changed (+13 additions, -1 deletions)

View changed files

📝 src/Session.php (+13 -1)

📄 Description

Currently if you call a refresh like this:

    $session = new Session(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI);
    $session->setRefreshToken($row['refresh_token']);
    $session->refreshAccessToken($row['refresh_token']);

    $access_token = $session->getAccessToken();
    $refresh_token = $session->getRefreshToken();
    $expiry = $session->getTokenExpiration();

You could end up with an error if the refresh token in the class isn't updated. This fixes this by setting the refresh token to the refresh token passed through if it hasn't been updated or isn't already set.

Also adds a setter for the refresh token which can be useful or an alternative to the above requiring an extra line of code before calling the refreshAccessToken method.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/jwilsson/spotify-web-api-php/pull/126 **Author:** [@shivampaw](https://github.com/shivampaw) **Created:** 5/31/2018 **Status:** ✅ Merged **Merged:** 6/3/2018 **Merged by:** [@jwilsson](https://github.com/jwilsson) **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (2) - [`efae404`](https://github.com/jwilsson/spotify-web-api-php/commit/efae404c9a9cc98b48bb47661337e409de0a054d) Allow the refresh token to be set - useful when automating a refresh - [`ef666f1`](https://github.com/jwilsson/spotify-web-api-php/commit/ef666f1c4c6fabf4b516b56692e6860fbfb9b513) When refreshing token, if one isn't set in the class then set it to the one passed through ### 📊 Changes **1 file changed** (+13 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/Session.php` (+13 -1) </details> ### 📄 Description Currently if you call a refresh like this: ``` $session = new Session(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI); $session->setRefreshToken($row['refresh_token']); $session->refreshAccessToken($row['refresh_token']); $access_token = $session->getAccessToken(); $refresh_token = $session->getRefreshToken(); $expiry = $session->getTokenExpiration(); ``` You could end up with an error if the refresh token in the class isn't updated. This fixes this by setting the refresh token to the refresh token passed through if it hasn't been updated or isn't already set. Also adds a setter for the refresh token which can be useful or an alternative to the above requiring an extra line of code before calling the `refreshAccessToken` method. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 19:26:51 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotify-web-api-php#262
No description provided.