public function getJsonWebTokensForLogin()

in modules/quanthub_core/src/Plugin/OpenidConnectRealm/QuantHubOpenidConnectRealm.php [204:231]


  public function getJsonWebTokensForLogin($state, $code) {
    $guzzle_client = new Client();

    try {
      $response = $guzzle_client->post($this->configuration[self::TOKEN_ENDPOINT], [
        'headers' => [
          'Content-Type' => 'application/json',
        ],
        'json' => [
          'scopes' => $this->configuration['scopes'],
          'authString' => $code,
        ],
      ]);

      // The User Info Data array that should contain token, expiresOn, tokenID.
      $user_info_data = json_decode($response->getBody(), TRUE);
    }
    catch (\Exception $e) {
      $this->logger->error('Failed to retrieve tokens for login from %endpoint: @error.', [
        '%endpoint' => $this->configuration[self::TOKEN_ENDPOINT],
        '@error' => $e->getMessage(),
      ]);

      throw new \RuntimeException('Failed to retrieve the user info', 0, $e);
    }

    return $this->getJsonWebTokensUserInfo($user_info_data);
  }