ExMCP.Authorization.FullOAuthFlow (ex_mcp v0.9.0)
View SourceFull OAuth 2.1 authorization code flow with PKCE for MCP.
Orchestrates the complete browser-based OAuth flow:
- Discover Protected Resource Metadata (RFC 9728)
- Discover Authorization Server metadata (RFC 8414 / OIDC)
- Dynamic Client Registration (RFC 7591) if no client_id
- Authorization Code flow with PKCE (RFC 7636)
- Local redirect URI server to receive callback
- Token exchange at token endpoint
This is used when a server returns 401 and the client has no
pre-existing credentials. For clients with credentials, use
ExMCP.Authorization.DiscoveryFlow instead.
Usage
{:ok, token} = FullOAuthFlow.execute(%{
resource_url: "http://localhost:3000/mcp",
redirect_port: 0 # auto-assign port
})
Summary
Functions
Execute the full OAuth flow.
Types
@type config() :: %{ :resource_url => String.t(), optional(:client_id) => String.t(), optional(:client_secret) => String.t(), optional(:redirect_port) => non_neg_integer(), optional(:scopes) => [String.t()], optional(:resource) => String.t() | [String.t()], optional(:http_client) => module(), optional(:www_authenticate) => String.t() }