Skip to content

Commit

Permalink
docs: clarify refresh token example in usage docs
Browse files Browse the repository at this point in the history
Resolves #1018

Co-authored-by: Murray Collingwood <[email protected]>
  • Loading branch information
ramsey and murraycollingwood committed Dec 11, 2024
1 parent 8b920f7 commit 0bfe348
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,16 @@ $provider = new \League\OAuth2\Client\Provider\GenericProvider([
]);

$existingAccessToken = getAccessTokenFromYourDataStore();
$existingRefreshToken = getRefreshTokenFromYourDataStore();

if ($existingAccessToken->hasExpired()) {
$newAccessToken = $provider->getAccessToken('refresh_token', [
'refresh_token' => $existingAccessToken->getRefreshToken()
$tokens = $provider->getAccessToken('refresh_token', [
'refresh_token' => $existingRefreshToken
]);

// Purge old access token and store new access token to your data store.
// Purge old tokens and store new ones to your data store.
saveNewAccessTokenToYourDataStore($tokens->getToken());
saveNewRefreshTokenToYourDataStore($tokens->getRefreshToken());
}
```

Expand Down

0 comments on commit 0bfe348

Please sign in to comment.