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

Copy Markdown View Source

Strict, bounded projection of OAuth token endpoint responses.

Unknown members and identity tokens are discarded immediately. Only a valid bearer access token, optional authorized refresh token, bounded expiry, and exact scope set can enter private grant state.

Summary

Types

grant_projection()

@type grant_projection() :: %{
  :access_token => binary(),
  :token_type => :bearer,
  :expires_in_ms => pos_integer() | nil,
  :granted_scopes => PtcRunner.Kernel.MCPOAuth.Scope.scope_set(),
  optional(:refresh_token) => binary()
}

Functions

access_token(value)

@spec access_token(term()) :: {:ok, binary()} | {:error, :invalid_access_token}

error(status, headers, body)

@spec error(non_neg_integer(), [{binary(), binary()}], binary()) ::
  {:ok, binary()} | {:error, :invalid_token_response}

refresh_token(value)

@spec refresh_token(term()) :: {:ok, binary()} | {:error, :invalid_refresh_token}

success(status, headers, body, opts)

@spec success(non_neg_integer(), [{binary(), binary()}], binary(), keyword()) ::
  {:ok, grant_projection()} | {:error, :invalid_token_response}