Select connections

Authentication

When a tool needs a connection, the session generates a Connect Link with session.authorize(), or the agent handles the flow through COMPOSIO_MANAGE_CONNECTIONS.

In chat, the agent can pause, ask the user to connect an app, then retry the tool once auth completes. Composio manages the OAuth redirects, token exchange, and refresh. Once a user connects a toolkit, the connected account persists and future sessions reuse it without re-authentication.

For OAuth toolkits, Composio uses managed apps by default. Bring your own app when you need your own branding, scopes, or consent screen.

If you only need authentication for tools you already own, follow managed authentication for your own tools. Use a session to create a Connect Link, then call provider APIs through Proxy Execute from your own code. You don't need to fetch tool schemas or replace your tools with catalog actions.

Custom auth configs

Use your own OAuth credentials instead of Composio's defaults. Pass an auth config ID per toolkit:

session = composio.sessions.create(
    user_id="user_123",
    auth_configs={
        "github": "ac_your_github_config",
        "slack": "ac_your_slack_config"
    }
)

See White-labeling authentication for branding, or Managed vs custom auth for toolkits that require your own credentials.

Account selection

When a user has multiple connected accounts for the same toolkit, specify which one the session uses:

session = composio.sessions.create(
    user_id="user_123",
    connected_accounts={
        "gmail": ["ca_work_gmail"],
        "github": ["ca_personal_github"],
    }
)

Arrays are the preferred format for connectedAccounts. A single string (e.g. "ca_work_gmail") is still accepted for backwards compatibility and is automatically coerced to a single-element array. Only one account per toolkit is allowed when multi-account mode is disabled.

Precedence

When executing a tool, the session selects the connected account in this order:

  1. The connectedAccounts override, if provided in the session config.
  2. The authConfigs override, which finds or creates a connection on that config.
  3. An auth config previously created for this toolkit.
  4. A new auth config created using Composio managed auth.
  5. Otherwise, an error if no Composio managed auth scheme exists for the toolkit.

When a user has multiple connected accounts for a toolkit, the session uses the most recently connected one.

If an account exists but the session doesn't use it, see When a session can't find a connected account.

authorize()

Manually authenticate a user to a toolkit outside of the chat flow.

connection_request = session.authorize(
    "github",
    callback_url="https://myapp.com/callback",
)

print(connection_request.redirect_url)

connected_account = connection_request.wait_for_connection()

For more details, see Manually authenticating users.

toolkits()

List the toolkits enabled for the session and their connection status, sorted by popularity. Use it to build a UI showing which apps are connected. Each toolkit includes its slug, name, logo, and connection status, and the call returns the first 20 by default.

toolkits = session.toolkits()

for toolkit in toolkits.items:
    connection = toolkit.connection
    if connection and connection.is_active and connection.connected_account:
        status = connection.connected_account.id
    else:
        status = "Not connected"
    print(f"{toolkit.name}: {status}")

Filter to only connected toolkits:

connected = session.toolkits(is_connected=True)

Paginate through every toolkit with limit and the returned cursor:

all_toolkits = []
cursor = None

while True:
    result = session.toolkits(limit=20, next_cursor=cursor)
    all_toolkits.extend(result.items)
    cursor = result.next_cursor
    if not cursor:
        break

For framework examples, see OpenAI or Vercel AI SDK. To connect over MCP, see Using sessions via MCP.