You are here

ClientCredentialsGrantService.php in OAuth2 Client 8.2

Same filename and directory in other branches
  1. 8.3 src/Service/Grant/ClientCredentialsGrantService.php

File

src/Service/Grant/ClientCredentialsGrantService.php
View source
<?php

namespace Drupal\oauth2_client\Service\Grant;

use League\OAuth2\Client\Provider\Exception\IdentityProviderException;

/**
 * Handles Authorization Grants for the OAuth2 Client module.
 */
class ClientCredentialsGrantService extends Oauth2ClientGrantServiceBase {

  /**
   * {@inheritdoc}
   */
  public function getAccessToken($clientId) {
    $provider = $this
      ->getProvider($clientId);
    try {
      $accessToken = $provider
        ->getAccessToken('client_credentials');
      $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);
  }

}

Classes

Namesort descending Description
ClientCredentialsGrantService Handles Authorization Grants for the OAuth2 Client module.