client = $client; $this->requestFactory = $requestFactory; } /** * @param array $params * * @return array */ public function introspect(OpenIDClient $client, string $token, array $params = []): array { $endpointUri = get_endpoint_uri($client, 'introspection_endpoint'); $authMethod = $client->getAuthMethodFactory() ->create($client->getMetadata()->getIntrospectionEndpointAuthMethod()); $tokenRequest = $this->requestFactory->createRequest('POST', $endpointUri) ->withHeader('content-type', 'application/x-www-form-urlencoded'); $params += [ 'token' => $token, 'aud' => $client->getIssuer()->getMetadata()->getIntrospectionEndpoint(), ]; $tokenRequest = $authMethod->createRequest($tokenRequest, $client, $params); $httpClient = $client->getHttpClient() ?? $this->client; try { $response = $httpClient->sendRequest($tokenRequest); } catch (ClientExceptionInterface $e) { throw new RuntimeException('Unable to get introspection response', 0, $e); } return parse_metadata_response($response, 200); } }