You are here

public function Oauth2ClientService::getProvider in OAuth2 Client 8.2

Same name and namespace in other branches
  1. 8.3 src/Service/Oauth2ClientService.php \Drupal\oauth2_client\Service\Oauth2ClientService::getProvider()

File

src/Service/Oauth2ClientService.php, line 98

Class

Oauth2ClientService
The OAuth2 Client service.

Namespace

Drupal\oauth2_client\Service

Code

public function getProvider($clientId) {
  $client = $this
    ->getClient($clientId);
  switch ($client
    ->getGrantType()) {
    case 'client_credentials':
      $provider = $this
        ->getClientCredentialsProvider($clientId);
      break;
    case 'resource_owner':
      $provider = $this
        ->getResourceOwnersCredentialsProvider($clientId);
      break;
    case 'authorization_code':
    default:
      $provider = $this
        ->getAuthorizationCodeProvider($clientId);
      break;
  }
  return $provider;
}