MCP.OAuth2.Loopback (fnord v0.8.71)

View Source

Minimal loopback HTTP server for OAuth2 Authorization Code callback.

Summary

Functions

Returns a specification to start this module under a supervisor.

Run the loopback flow until one callback is handled or timeout. Returns the token map on success.

Start the server and return {pid, port} so the caller can construct the redirect_uri.

Start the loopback server on 127.0.0.1:0, returning bound port.

Types

t()

@type t() :: %{
  server_ref: pid(),
  port: non_neg_integer(),
  state: String.t(),
  code_verifier: String.t(),
  cfg: map(),
  server_key: String.t()
}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

run(cfg, base_url, server_key, expected_state, code_verifier, port \\ 0, timeout_ms \\ 120_000)

@spec run(
  map(),
  String.t(),
  String.t(),
  String.t(),
  String.t(),
  non_neg_integer(),
  non_neg_integer()
) :: {:ok, map()} | {:error, term()}

Run the loopback flow until one callback is handled or timeout. Returns the token map on success.

start(cfg, server_key, expected_state, code_verifier, port \\ 0)

@spec start(map(), String.t(), String.t(), String.t(), non_neg_integer()) ::
  {:ok, pid(), non_neg_integer()} | {:error, term()}

Start the server and return {pid, port} so the caller can construct the redirect_uri.

start_link(opts)

@spec start_link(keyword()) :: GenServer.on_start()

Start the loopback server on 127.0.0.1:0, returning bound port.