Token Introspection¶
OAuth 2.0 Token Introspection (RFC 7662) for validating tokens and obtaining metadata.
Request Model¶
TokenIntrospectionRequest(address, token, client_id, token_type_hint=None, client_secret=None)
dataclass
¶
Bases: BaseRequest
Request for OAuth 2.0 Token Introspection (RFC 7662).
Attributes:
| Name | Type | Description |
|---|---|---|
address |
str
|
The introspection endpoint URL. |
token |
str
|
The token to introspect. |
client_id |
str
|
The client identifier for authentication. |
token_type_hint |
str | None
|
Optional hint — |
client_secret |
str | None
|
Client secret for authentication (optional for public clients). |
Response Model¶
TokenIntrospectionResponse(is_successful, error=None, claims=None)
dataclass
¶
Bases: BaseResponse
Response from a token introspection endpoint (RFC 7662).
Check is_successful before accessing claims.
The claims dict contains at minimum active: bool.
When active is True, additional claims like scope,
client_id, username, exp, iat, sub, aud,
iss, and jti may be present.
Functions¶
introspect_token(request, http_client=None)
¶
Introspect an OAuth 2.0 token (RFC 7662).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
TokenIntrospectionRequest
|
Introspection request with token and client credentials. |
required |
http_client
|
HTTPClient | None
|
Optional managed HTTP client. |
None
|
Returns:
| Type | Description |
|---|---|
TokenIntrospectionResponse
|
TokenIntrospectionResponse with claims dict including |