PtcRunner.Kernel.MCPOAuth.Authorization (PtcRunner v0.14.0)

Copy Markdown View Source

Callback-agnostic explicit MCP OAuth authorization operations.

begin_authorization/3 discovers and freezes the resource/server/client binding, creates one pending flow, and returns a one-time URL. Completion consumes state exactly once, takes the shared grant mutation lease, crosses the durable code-dispatch fence, exchanges the code once, and atomically installs the new grant. No operation opens a browser or runs during ordinary MCP execution.

Summary

Functions

begin_authorization(context, authority, opts)

cancel_authorization(context, pending, opts)

@spec cancel_authorization(
  PtcRunner.Kernel.MCPOAuth.Context.t(),
  PtcRunner.Kernel.MCPOAuth.PendingAuthorization.t(),
  keyword()
) :: :ok | {:error, atom()}

Cancels one pending authorization under a supplied terminal deadline.

The :cleanup_deadline option is required and belongs to the lifecycle owner that installed the provider cleanup budget. Cancellation is terminal cleanup, so it is never charged whatever remained of the interaction it cleans up, and a caller must not treat an uncommitted cancellation as success.

complete_authorization(context, pending, parameters, opts)

@spec complete_authorization(
  PtcRunner.Kernel.MCPOAuth.Context.t(),
  PtcRunner.Kernel.MCPOAuth.PendingAuthorization.t(),
  [{binary(), binary()}],
  keyword()
) :: {:ok, map()} | {:error, atom()}