Skip to content

UserInfo

OpenID Connect UserInfo endpoint (OIDC Core 1.0 Section 5.3).

Request / Response Models

UserInfoRequest(address, token, expected_sub=None, dpop_key=None, mtls=None) dataclass

Bases: BaseRequest

Request for the OpenID Connect UserInfo endpoint.

Attributes:

Name Type Description
address str

The UserInfo endpoint URL.

token str

A valid access token with openid scope.

expected_sub str | None

Expected sub claim from the ID token for verification per OIDC Core 1.0 Section 5.3.4. When provided, the sub in the UserInfo response is compared against this value and a mismatch produces an error response.

dpop_key DPoPKey | None

When set, the UserInfo request is DPoP-bound (RFC 9449): the access token is presented with Authorization: DPoP <token> and a resource-request DPoP proof (carrying the ath access-token hash) is attached, honoring the use_dpop_nonce challenge with a single retry. Required to use a sender-constrained access token at the resource server (FAPI 2.0).

mtls MtlsClientAuth | None

When set, the UserInfo/resource request presents this client certificate at the TLS layer (RFC 8705) — required to use an mTLS certificate-bound access token at the resource server.

UserInfoResponse(is_successful, error=None, claims=None, raw=None) dataclass

Bases: BaseResponse

Response from the UserInfo endpoint.

Check is_successful before accessing claims or raw.

Sync API

get_userinfo(request, http_client=None)

Get claims about an authenticated user from the UserInfo endpoint.

Parameters:

Name Type Description Default
request UserInfoRequest

UserInfo request with endpoint address and access token

required
http_client HTTPClient | None

Optional managed HTTP client. When None, uses the thread-local default.

None

Returns:

Name Type Description
UserInfoResponse UserInfoResponse

Response with claims (JSON) or raw JWT string

Async API

get_userinfo(request, http_client=None) async

Get claims about an authenticated user from the UserInfo endpoint (async).

Parameters:

Name Type Description Default
request UserInfoRequest

UserInfo request with endpoint address and access token

required
http_client AsyncHTTPClient | None

Optional managed HTTP client. When None, uses the module-level singleton.

None

Returns:

Name Type Description
UserInfoResponse UserInfoResponse

Response with claims (JSON) or raw JWT string