You are here

protected function OpenIDConnect::parseToken in OpenID Connect / OAuth client 2.x

Parse JWT token.

Parameters

string $token: The encoded ID token containing the user data.

Return value

array|string The parsed JWT token or the original string.

1 call to OpenIDConnect::parseToken()
OpenIDConnect::buildContext in src/OpenIDConnect.php
Fill the context array.

File

src/OpenIDConnect.php, line 712

Class

OpenIDConnect
Main service of the OpenID Connect module.

Namespace

Drupal\openid_connect

Code

protected function parseToken(string $token) {
  $parts = explode('.', $token, 3);
  if (count($parts) === 3) {
    $decoded = Json::decode(base64_decode($parts[1]));
    if (is_array($decoded)) {
      return $decoded;
    }
  }
  return $token;
}