You are here

class RefreshTokenGrantService in OAuth2 Client 8.2

Same name and namespace in other branches
  1. 8.3 src/Service/Grant/RefreshTokenGrantService.php \Drupal\oauth2_client\Service\Grant\RefreshTokenGrantService

Handles Authorization Grants for the OAuth2 Client module.

Hierarchy

Expanded class hierarchy of RefreshTokenGrantService

1 string reference to 'RefreshTokenGrantService'
oauth2_client.services.yml in ./oauth2_client.services.yml
oauth2_client.services.yml

File

src/Service/Grant/RefreshTokenGrantService.php, line 8

Namespace

Drupal\oauth2_client\Service\Grant
View source
class RefreshTokenGrantService extends Oauth2ClientGrantServiceBase {

  /**
   * {@inheritdoc}
   */
  public function getAccessToken($clientId) {
    $accessToken = $this->state
      ->get('oauth2_client_access_token-' . $clientId);
    if ($accessToken && $accessToken
      ->getExpires() && $accessToken
      ->hasExpired()) {
      $provider = $this
        ->getProvider($clientId);
      $newAccessToken = $provider
        ->getAccessToken('refresh_token', [
        'refresh_token' => $accessToken
          ->getRefreshToken(),
      ]);
      $this
        ->storeAccessToken($clientId, $newAccessToken);
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getGrantProvider($clientId) {
    return $this
      ->getProvider($clientId);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Oauth2ClientGrantServiceBase::$clientProviderCache protected property Client provider cache
Oauth2ClientGrantServiceBase::$currentRequest protected property The Request Stack.
Oauth2ClientGrantServiceBase::$oauth2ClientPluginManager protected property The OAuth2 Client plugin manager.
Oauth2ClientGrantServiceBase::$state protected property The Drupal state.
Oauth2ClientGrantServiceBase::$urlGenerator protected property The URL generator service.
Oauth2ClientGrantServiceBase::getProvider protected function Creates a new provider object.
Oauth2ClientGrantServiceBase::getRedirectUri private function Retrieves the local redirect URI used for OAuth2 authentication.
Oauth2ClientGrantServiceBase::storeAccessToken protected function Store an access token to the Drupal state.
Oauth2ClientGrantServiceBase::__construct public function Construct an OAuth2Client object. 1
Oauth2ClientServiceBase::clearAccessToken public function Clears the access token for the given client. Overrides Oauth2ClientServiceInterface::clearAccessToken
Oauth2ClientServiceBase::getClient public function Retrieve an OAuth2 Client Plugin. Overrides Oauth2ClientServiceInterface::getClient
Oauth2ClientServiceBase::retrieveAccessToken public function Retrieve an access token from the Drupal state. Overrides Oauth2ClientServiceInterface::retrieveAccessToken
RefreshTokenGrantService::getAccessToken public function Get an OAuth2 access token. Overrides Oauth2ClientGrantServiceInterface::getAccessToken
RefreshTokenGrantService::getGrantProvider public function Get the league/oauth2 provider. Overrides Oauth2ClientGrantServiceInterface::getGrantProvider