ExAgent. MCP. OAuth
(ExAgent v3.0.0)
View Source
Pure OAuth helpers for the MCP client host.
Stability — Candidate.
Select an issuer from trusted protected resource metadata, then fetch
metadata_urls/1 in order and validate the document with validate_metadata/2.
The host owns HTTP policy, authorization redirects, OAuth state, the code
exchange, token custody and token refresh. Keep the validated issuer and PKCE
verifier together in the host's per-authorization record.
Summary
Functions
Return the RFC 8414 and OpenID Connect discovery URLs in MCP priority order.
Derive the unpadded base64url S256 challenge from an RFC 7636 verifier.
Encode 32 to 96 bytes of host-generated random entropy as a PKCE verifier.
Check the decoded authorization-response iss against the issuer recorded
before redirect. Use for both success and error callbacks, before consuming
their contents. The host also verifies the callback's binding and state.
Validate issuer identity, HTTPS endpoints and advertised PKCE S256 support for the authorization code flow. Pass the issuer used to construct the discovery URL and the decoded document fetched over trusted HTTPS.
Types
Functions
Return the RFC 8414 and OpenID Connect discovery URLs in MCP priority order.
Derive the unpadded base64url S256 challenge from an RFC 7636 verifier.
Encode 32 to 96 bytes of host-generated random entropy as a PKCE verifier.
Check the decoded authorization-response iss against the issuer recorded
before redirect. Use for both success and error callbacks, before consuming
their contents. The host also verifies the callback's binding and state.
Validate issuer identity, HTTPS endpoints and advertised PKCE S256 support for the authorization code flow. Pass the issuer used to construct the discovery URL and the decoded document fetched over trusted HTTPS.
Returns {:error, :pkce_unsupported} unless code_challenge_methods_supported
is an array of strings containing "S256".
MCP Authorization Code Protection