You are here

public function AuthHelper::getUserUsingRefreshToken in Auth0 Single Sign On 8.2

Get the user using token.

Parameters

string $refreshToken: The refresh token to use to get the user.

Return value

array A user array of named claims from the ID token.

Throws

RefreshTokenFailedException

CoreException

InvalidTokenException

File

src/Util/AuthHelper.php, line 83
Contains \Drupal\auth0\Util\AuthHelper.

Class

AuthHelper
Controller routines for auth0 authentication.

Namespace

Drupal\auth0\Util

Code

public function getUserUsingRefreshToken($refreshToken) {
  global $base_root;
  $auth0Api = new Authentication($this
    ->getAuthDomain(), $this->clientId, $this->clientSecret);
  try {
    $tokens = $auth0Api
      ->oauth_token([
      'grant_type' => 'refresh_token',
      'client_id' => $this->clientId,
      'client_secret' => $this->clientSecret,
      'refresh_token' => $refreshToken,
    ]);
    return $this
      ->validateIdToken($tokens->idToken);
  } catch (\Exception $e) {
    throw new RefreshTokenFailedException($e);
  }
}