-
Notifications
You must be signed in to change notification settings - Fork 0
Refreshing a Token
Oliver Schlöbe edited this page Jun 3, 2019
·
1 revision
Once your application is authorized, you can refresh an expired token using a refresh token rather than going through the entire process of obtaining a brand new token. To do so, simply reuse this refresh token from your data store to request a refresh.
$rbtvProvider = new \OliverSchloebe\OAuth2\Client\Provider\Rbtv([
'clientId' => 'yourId', // The client ID of your RBTV app
'clientSecret' => 'yourSecret', // The client password of your RBTV app
'redirectUri' => 'yourRedirectUri' // The return URL you specified for your app on RBTV
]);
$existingAccessToken = getAccessTokenFromYourDataStore();
if ($existingAccessToken->hasExpired()) {
$newAccessToken = $rbtvProvider->getAccessToken('refresh_token', [
'refresh_token' => $existingAccessToken->getRefreshToken()
]);
// Purge old access token and store new access token to your data store.
}