ExBifrost.Api.OAuth (ex_bifrost v0.1.0)

Copy Markdown View Source

API calls for all endpoints tagged OAuth.

Summary

Functions

Complete MCP client OAuth flow Completes the OAuth flow for an MCP client after the user has authorized the request. This endpoint should be called after the OAuth provider redirects back to the callback endpoint and the OAuth token has been stored. It retrieves the pending MCP client configuration and establishes the connection with the OAuth-provided credentials.

Get OAuth config status Retrieves the current status of an OAuth configuration. Shows whether the OAuth flow is pending, authorized, or failed, and includes token expiration and scopes if authorized.

Get per-user OAuth flow detail Returns the pending OAuth flow row metadata: which MCP client is being authorized, which identity (user / VK / session) the resulting token will be bound to, and whether an active token already exists for that binding (has_active_token). Requires management API authentication via Authorization: Bearer <API key>.

OAuth callback endpoint Handles the OAuth provider callback after user authorization. This endpoint processes the authorization code and exchanges it for an access token. On success, displays an HTML page that closes the authorization window.

Revoke OAuth config Revokes a server-level OAuth configuration and its associated access token. After revocation, the MCP client will no longer be able to use this OAuth token.

Start the upstream OAuth authorization for a pending flow Reconstructs the upstream provider's authorize URL for a pending OAuth flow. The auth-landing page redirects the browser to that URL; the user completes upstream auth; the upstream provider redirects back to /api/oauth/callback, which exchanges the code for tokens server-side and stores them against the flow's identity. Returns 410 if the flow is no longer pending (expired / completed / failed). The caller should restart the original action to get a fresh flow.

Functions

complete_mcp_client_o_auth(connection, id, opts \\ [])

@spec complete_mcp_client_o_auth(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, ExBifrost.Model.SuccessResponse.t()}
  | {:ok, ExBifrost.Model.BifrostError.t()}
  | {:error, Tesla.Env.t()}

Complete MCP client OAuth flow Completes the OAuth flow for an MCP client after the user has authorized the request. This endpoint should be called after the OAuth provider redirects back to the callback endpoint and the OAuth token has been stored. It retrieves the pending MCP client configuration and establishes the connection with the OAuth-provided credentials.

Parameters

  • connection (ExBifrost.Connection): Connection to server
  • id (String.t): MCP client ID
  • opts (keyword): Optional parameters

Returns

  • {:ok, ExBifrost.Model.SuccessResponse.t} on success
  • {:error, Tesla.Env.t} on failure

get_o_auth_config_status(connection, id, opts \\ [])

Get OAuth config status Retrieves the current status of an OAuth configuration. Shows whether the OAuth flow is pending, authorized, or failed, and includes token expiration and scopes if authorized.

Parameters

  • connection (ExBifrost.Connection): Connection to server
  • id (String.t): OAuth config ID
  • opts (keyword): Optional parameters

Returns

  • {:ok, ExBifrost.Model.OAuthConfigStatus.t} on success
  • {:error, Tesla.Env.t} on failure

get_per_user_oauth_flow(connection, id, opts \\ [])

@spec get_per_user_oauth_flow(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, ExBifrost.Model.McpOauthFlowDetail.t()}
  | {:ok, ExBifrost.Model.BifrostError.t()}
  | {:error, Tesla.Env.t()}

Get per-user OAuth flow detail Returns the pending OAuth flow row metadata: which MCP client is being authorized, which identity (user / VK / session) the resulting token will be bound to, and whether an active token already exists for that binding (has_active_token). Requires management API authentication via Authorization: Bearer <API key>.

Parameters

  • connection (ExBifrost.Connection): Connection to server
  • id (String.t): Flow row ID
  • opts (keyword): Optional parameters

Returns

  • {:ok, ExBifrost.Model.McpOauthFlowDetail.t} on success
  • {:error, Tesla.Env.t} on failure

handle_o_auth_callback(connection, state, opts \\ [])

@spec handle_o_auth_callback(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, String.t()} | {:error, Tesla.Env.t()}

OAuth callback endpoint Handles the OAuth provider callback after user authorization. This endpoint processes the authorization code and exchanges it for an access token. On success, displays an HTML page that closes the authorization window.

Parameters

  • connection (ExBifrost.Connection): Connection to server
  • state (String.t): State parameter for OAuth security (CSRF protection)
  • opts (keyword): Optional parameters
    • :code (String.t): Authorization code from the OAuth provider. Present on success only; code and error are mutually exclusive — one of them is always set.
    • :error (String.t): Error code if authorization failed. Mutually exclusive with code.
    • :error_description (String.t): Error description if authorization failed

Returns

  • {:ok, String.t} on success
  • {:error, Tesla.Env.t} on failure

revoke_o_auth_config(connection, id, opts \\ [])

@spec revoke_o_auth_config(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, ExBifrost.Model.SuccessResponse.t()}
  | {:ok, ExBifrost.Model.BifrostError.t()}
  | {:error, Tesla.Env.t()}

Revoke OAuth config Revokes a server-level OAuth configuration and its associated access token. After revocation, the MCP client will no longer be able to use this OAuth token.

Parameters

  • connection (ExBifrost.Connection): Connection to server
  • id (String.t): OAuth config ID
  • opts (keyword): Optional parameters

Returns

  • {:ok, ExBifrost.Model.SuccessResponse.t} on success
  • {:error, Tesla.Env.t} on failure

start_per_user_oauth_flow(connection, id, opts \\ [])

Start the upstream OAuth authorization for a pending flow Reconstructs the upstream provider's authorize URL for a pending OAuth flow. The auth-landing page redirects the browser to that URL; the user completes upstream auth; the upstream provider redirects back to /api/oauth/callback, which exchanges the code for tokens server-side and stores them against the flow's identity. Returns 410 if the flow is no longer pending (expired / completed / failed). The caller should restart the original action to get a fresh flow.

Parameters

  • connection (ExBifrost.Connection): Connection to server
  • id (String.t): Flow row ID
  • opts (keyword): Optional parameters

Returns

  • {:ok, ExBifrost.Model.StartPerUserOauthFlow200Response.t} on success
  • {:error, Tesla.Env.t} on failure