ResourceOwnersCredentialsGrantService.php in OAuth2 Client 8.2
File
src/Service/Grant/ResourceOwnersCredentialsGrantService.php
View source
<?php
namespace Drupal\oauth2_client\Service\Grant;
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
class ResourceOwnersCredentialsGrantService extends Oauth2ClientGrantServiceBase {
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) {
watchdog_exception('OAuth2 Client', $e);
}
}
public function getGrantProvider($clientId) {
return $this
->getProvider($clientId);
}
}