RefreshTokenGrantService.php in OAuth2 Client 8.2
File
src/Service/Grant/RefreshTokenGrantService.php
View source
<?php
namespace Drupal\oauth2_client\Service\Grant;
class RefreshTokenGrantService extends Oauth2ClientGrantServiceBase {
public function getAccessToken($clientId) {
$accessToken = $this->state
->get('oauth2_client_access_token-' . $clientId);
if ($accessToken && $accessToken
->getExpires() && $accessToken
->hasExpired()) {
$provider = $this
->getProvider($clientId);
$newAccessToken = $provider
->getAccessToken('refresh_token', [
'refresh_token' => $accessToken
->getRefreshToken(),
]);
$this
->storeAccessToken($clientId, $newAccessToken);
}
}
public function getGrantProvider($clientId) {
return $this
->getProvider($clientId);
}
}