Skip to content

IntrospectionClient

A ~30-line RFC 7662 (OAuth 2.0 Token Introspection) POST helper — league/oauth2-client has none.

Used only on revocation-sensitive paths; the default resource-server validation is local JWKS verification via packages/auth-jwt.

final class IntrospectionClient

Since1.0.0
SourceIntrospectionClient.php

public function __construct(ClientInterface $httpClient, RequestFactoryInterface $requestFactory, StreamFactoryInterface $streamFactory, string $introspectionEndpoint, string $clientId, string $clientSecret): mixed

The OAuth client secret, sent via HTTP Basic per RFC 7662 §2.1.

ParameterTypeDescription
$httpClientClientInterfaceA PSR-18 HTTP client.
$requestFactoryRequestFactoryInterfaceA PSR-17 request factory.
$streamFactoryStreamFactoryInterfaceA PSR-17 stream factory, for the POST body.
$introspectionEndpointstringThe authorization server’s RFC 7662 introspection endpoint.
$clientIdstringThe OAuth client id, sent via HTTP Basic per RFC 7662 §2.1.
$clientSecretstringThe OAuth client secret, sent via HTTP Basic per RFC 7662 §2.1.

Returns mixed

MethodDescription
fromDiscovery(OidcDiscoveryDocument $document, ClientInterface $httpClient, RequestFactoryInterface $requestFactory, StreamFactoryInterface $streamFactory, string $clientId, string $clientSecret): selfBuilds a client from a provider’s discovery document (see OidcDiscoveryClient).
introspect(string $token): array<string, mixed>

public static function fromDiscovery(OidcDiscoveryDocument $document, ClientInterface $httpClient, RequestFactoryInterface $requestFactory, StreamFactoryInterface $streamFactory, string $clientId, string $clientSecret): self

Builds a client from a provider’s discovery document (see OidcDiscoveryClient).

The OAuth client secret, sent via HTTP Basic per RFC 7662 §2.1.

ParameterTypeDescription
$documentOidcDiscoveryDocumentThe provider’s metadata.
$httpClientClientInterfaceA PSR-18 HTTP client.
$requestFactoryRequestFactoryInterfaceA PSR-17 request factory.
$streamFactoryStreamFactoryInterfaceA PSR-17 stream factory, for the POST body.
$clientIdstringThe OAuth client id, sent via HTTP Basic per RFC 7662 §2.1.
$clientSecretstringThe OAuth client secret, sent via HTTP Basic per RFC 7662 §2.1.

Returns self — A client wired to the discovered introspection endpoint.

ThrowsWhen
AuthenticationExceptionIf the document does not advertise an introspection endpoint.

public function introspect(string $token): array<string, mixed>

The token to introspect.

ParameterTypeDescription
$tokenstringThe token to introspect.

Returns array``<``string``, ``mixed``> — The introspection response.

ThrowsWhen
AuthenticationExceptionIf the request fails, the response is malformed, or the token is not active.