public function RefreshTokenGrantService::getAccessToken in OAuth2 Client 8.3
Same name and namespace in other branches
- 8.2 src/Service/Grant/RefreshTokenGrantService.php \Drupal\oauth2_client\Service\Grant\RefreshTokenGrantService::getAccessToken()
Get an OAuth2 access token.
Parameters
string $pluginId: The plugin ID of the OAuth2 Client plugin for which an access token should be retrieved.
Overrides Oauth2ClientGrantServiceInterface::getAccessToken
File
- src/
Service/ Grant/ RefreshTokenGrantService.php, line 15
Class
- RefreshTokenGrantService
- Handles Authorization Grants for the OAuth2 Client module.
Namespace
Drupal\oauth2_client\Service\GrantCode
public function getAccessToken($pluginId) {
$accessToken = $this
->retrieveAccessToken($pluginId);
if ($accessToken instanceof AccessTokenInterface) {
$expirationTimestamp = $accessToken
->getExpires();
if (!empty($expirationTimestamp) && $accessToken
->hasExpired()) {
$provider = $this
->getProvider($pluginId);
$newAccessToken = $provider
->getAccessToken('refresh_token', [
'refresh_token' => $accessToken
->getRefreshToken(),
]);
$this
->storeAccessToken($pluginId, $newAccessToken);
}
}
}