You are here

public function AuthCodeExample::storeAccessToken in OAuth2 Client 8.3

Stores access tokens obtained by this client.

Parameters

\League\OAuth2\Client\Token\AccessToken $accessToken: The token to store.

Overrides Oauth2ClientPluginInterface::storeAccessToken

File

examples/oauth2_client_example_plugins/src/Plugin/Oauth2Client/AuthCodeExample.php, line 34

Class

AuthCodeExample
Auth code example.

Namespace

Drupal\oauth2_client_example_plugins\Plugin\Oauth2Client

Code

public function storeAccessToken(AccessToken $accessToken) {
  $this->state
    ->set('oauth2_client_access_token-' . $this
    ->getId(), $accessToken);
  if ($this
    ->displaySuccessMessage()) {
    $this->messenger
      ->addStatus($this
      ->t('OAuth token stored.'));
  }
}