Skip to content

Token Revocation

OAuth 2.0 Token Revocation (RFC 7009) for revoking access and refresh tokens.

Request Model

TokenRevocationRequest(address, token, client_id, token_type_hint=None, client_secret=None) dataclass

Bases: BaseRequest

Request for OAuth 2.0 Token Revocation (RFC 7009).

Attributes:

Name Type Description
address str

The revocation endpoint URL.

token str

The token to revoke.

client_id str

The client identifier for authentication.

token_type_hint str | None

Optional hint — "access_token" or "refresh_token".

client_secret str | None

Client secret for authentication (optional for public clients).

Response Model

TokenRevocationResponse(is_successful, error=None) dataclass

Bases: BaseResponse

Response from a token revocation endpoint (RFC 7009).

A successful revocation returns is_successful=True with no data fields. Per RFC 7009, the server responds with 200 even if the token was already invalid.

Functions

Synchronous

revoke_token(request, http_client=None)

Revoke an OAuth 2.0 token (RFC 7009).

Parameters:

Name Type Description Default
request TokenRevocationRequest

Revocation request with token and client credentials.

required
http_client HTTPClient | None

Optional managed HTTP client.

None

Returns:

Type Description
TokenRevocationResponse

TokenRevocationResponse indicating success or error.

Asynchronous

revoke_token(request, http_client=None) async

Revoke an OAuth 2.0 token (RFC 7009, async).

Parameters:

Name Type Description Default
request TokenRevocationRequest

Revocation request with token and client credentials.

required
http_client AsyncHTTPClient | None

Optional managed HTTP client.

None

Returns:

Type Description
TokenRevocationResponse

TokenRevocationResponse indicating success or error.