You are here

function oauth2_client_get_token in OAuth2 Client 8

Same name in this branch
  1. 8 oauth2_client.module \oauth2_client_get_token()
  2. 8 oauth2_client.api.php \oauth2_client_get_token()
Same name and namespace in other branches
  1. 7.2 oauth2_client.module \oauth2_client_get_token()
  2. 7.2 oauth2_client.api.php \oauth2_client_get_token()
  3. 7 oauth2_client.module \oauth2_client_get_token()

Returns the access token of the oauth2_client with the given $id.

File

./oauth2_client.module, line 138
Provides OAuth2 client functionality.

Code

function oauth2_client_get_token($id) {
  $tempstore = \Drupal::service('tempstore.private')
    ->get('oauth2_client');
  $tokens = $tempstore
    ->get('token');
  if (isset($tokens[$id])) {
    return $tokens[$id];
  }
  else {
    return [
      'access_token' => NULL,
      'refresh_token' => NULL,
      'expires_in' => NULL,
      'expiration_time' => NULL,
      'scope' => NULL,
    ];
  }
}