class ResourceOwnersCredentialsGrantService in OAuth2 Client 8.2
Same name and namespace in other branches
- 8.3 src/Service/Grant/ResourceOwnersCredentialsGrantService.php \Drupal\oauth2_client\Service\Grant\ResourceOwnersCredentialsGrantService
Handles Authorization Grants for the OAuth2 Client module.
Hierarchy
- class \Drupal\oauth2_client\Service\Oauth2ClientServiceBase implements Oauth2ClientServiceInterface
- class \Drupal\oauth2_client\Service\Grant\Oauth2ClientGrantServiceBase implements Oauth2ClientGrantServiceInterface
- class \Drupal\oauth2_client\Service\Grant\ResourceOwnersCredentialsGrantService
- class \Drupal\oauth2_client\Service\Grant\Oauth2ClientGrantServiceBase implements Oauth2ClientGrantServiceInterface
Expanded class hierarchy of ResourceOwnersCredentialsGrantService
1 string reference to 'ResourceOwnersCredentialsGrantService'
File
- src/
Service/ Grant/ ResourceOwnersCredentialsGrantService.php, line 10
Namespace
Drupal\oauth2_client\Service\GrantView source
class ResourceOwnersCredentialsGrantService extends Oauth2ClientGrantServiceBase {
/**
* {@inheritdoc}
*/
public function getAccessToken($clientId) {
$provider = $this
->getProvider($clientId);
$client = $this
->getClient($clientId);
try {
$accessToken = $provider
->getAccessToken('password', [
'username' => $client
->getUsername(),
'password' => $client
->getPassword(),
]);
$this
->storeAccessToken($clientId, $accessToken);
} catch (IdentityProviderException $e) {
// Failed to get the access token.
watchdog_exception('OAuth2 Client', $e);
}
}
/**
* {@inheritdoc}
*/
public function getGrantProvider($clientId) {
return $this
->getProvider($clientId);
}
}