public function Oauth2ClientService::getAccessToken in OAuth2 Client 8.2
Same name and namespace in other branches
- 8.3 src/Service/Oauth2ClientService.php \Drupal\oauth2_client\Service\Oauth2ClientService::getAccessToken()
File
- src/
Service/ Oauth2ClientService.php, line 72
Class
- Oauth2ClientService
- The OAuth2 Client service.
Namespace
Drupal\oauth2_client\ServiceCode
public function getAccessToken($clientId) {
$access_token = $this
->retrieveAccessToken($clientId);
if (!$access_token || $access_token
->getExpires() && $access_token
->hasExpired()) {
$client = $this
->getClient($clientId);
switch ($client
->getGrantType()) {
case 'authorization_code':
$access_token = $this
->getAuthorizationCodeAccessToken($clientId);
break;
case 'client_credentials':
$access_token = $this
->getClientCredentialsAccessToken($clientId);
break;
case 'resource_owner':
$access_token = $this
->getResourceOwnersCredentialsAccessToken($clientId);
break;
}
}
return $access_token;
}