public function RefreshTokenGrantService::getAccessToken in OAuth2 Client 8.2
Same name and namespace in other branches
- 8.3 src/Service/Grant/RefreshTokenGrantService.php \Drupal\oauth2_client\Service\Grant\RefreshTokenGrantService::getAccessToken()
Get an OAuth2 access token.
Parameters
string $clientId: 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 13
Class
- RefreshTokenGrantService
- Handles Authorization Grants for the OAuth2 Client module.
Namespace
Drupal\oauth2_client\Service\GrantCode
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);
}
}