barrel_mcp_client_auth behaviour (barrel_mcp v3.0.1)
View SourceAuthorization behaviour for barrel_mcp_client.
The HTTP transport calls into this module to obtain the bearer token to attach to outgoing requests, and to refresh the token when the server returns 401.
A handle is an opaque term passed back into every callback. Static bearer tokens use barrel_mcp_client_auth_bearer; OAuth 2.1 with PKCE will use barrel_mcp_client_auth_oauth (Phase D).
Summary
Functions
Answer a server's refusal with a new handle. Runs the handle's challenge/2 when it has one, else its refresh/2 with the header. May take as long as a person takes to authorize; the transport calls it from a worker, never inline.
Lookup the Authorization header for the current state.
Construct an auth handle from a user-facing config term.
Refresh after a 401, returning a new handle.
Extra headers for one request, and the handle after issuing them.
Tell the handle a request was accepted.
Types
Callbacks
Functions
Answer a server's refusal with a new handle. Runs the handle's challenge/2 when it has one, else its refresh/2 with the header. May take as long as a person takes to authorize; the transport calls it from a worker, never inline.
Lookup the Authorization header for the current state.
-spec new(none | {bearer, binary()} | {oauth, map()} | {oauth_client_credentials, map()} | {oauth_enterprise, map()} | {oauth_jwt_bearer, map()}) -> t() | {error, term()}.
Construct an auth handle from a user-facing config term.
Refresh after a 401, returning a new handle.
Extra headers for one request, and the handle after issuing them.
Tell the handle a request was accepted.