@devries-cameron20 / composio Mirror · read-only / commits / f5818d9bb
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 07:15 UTC

docs: preserve proxy owner and recoverable auth polling

Brendan O'Leary committed Oct 29, 2026 at 19:36 UTC f5818d9bb11bda5f75057c861f23ac0e8873e9cd
1 file changed +8 -5
docs/content/docs/authentication/managed-auth-for-custom-tools.mdx
+8 -5
@@ -33,6 +33,7 @@ account = connection.wait_for_connection(60)
33
34 def read_github_profile(connected_account_id: str):
35 return composio.tools.proxy(
36 + user_id=owner_id,
37 connected_account_id=connected_account_id,
38 endpoint="/user",
39 method="GET",
@@ -58,6 +59,7 @@ const account = await connection.waitForConnection(60000);
59
60 function readGitHubProfile(connectedAccountId: string) {
61 return composio.tools.proxyExecute({
62 + userId: ownerId,
63 connectedAccountId,
64 endpoint: '/user',
65 method: 'GET',
@@ -73,10 +75,11 @@ console.log(await readGitHubProfile(account.id));
75 set -euo pipefail
76
77 # Resolve this owner from your authenticated application session.
78 +OWNER_ID="org_42:user_7"
79 SESSION_ID=$(curl --fail-with-body -s -X POST https://backend.composio.dev/api/v3.1/tool_router/session \
80 -H "x-api-key: $COMPOSIO_API_KEY" \
81 -H "Content-Type: application/json" \
79 - -d '{"user_id":"org_42:user_7","toolkits":{"enable":["github"]}}' | jq -r '.session_id')
82 + -d "{\"user_id\":\"$OWNER_ID\",\"toolkits\":{\"enable\":[\"github\"]}}" | jq -r '.session_id')
83
84 CONNECTION=$(curl --fail-with-body -s -X POST https://backend.composio.dev/api/v3.1/tool_router/session/$SESSION_ID/link \
85 -H "x-api-key: $COMPOSIO_API_KEY" \
@@ -93,7 +96,7 @@ while true; do
96 STATUS=$(echo "$ACCOUNT" | jq -r '.status')
97 case "$STATUS" in
98 ACTIVE) break ;;
96 - FAILED|EXPIRED|INACTIVE|REVOKED) echo "Connection ended: $STATUS" >&2; exit 1 ;;
99 + FAILED|EXPIRED|REVOKED) echo "Connection ended: $STATUS" >&2; exit 1 ;;
100 esac
101 if [ "$SECONDS" -ge "$DEADLINE" ]; then
102 echo "Timed out waiting for authorization" >&2
@@ -106,14 +109,14 @@ done
109 curl --fail-with-body -s -X POST https://backend.composio.dev/api/v3.1/tools/execute/proxy \
110 -H "x-api-key: $COMPOSIO_API_KEY" \
111 -H "Content-Type: application/json" \
109 - -d "{\"connected_account_id\":\"$CONNECTED_ACCOUNT_ID\",\"endpoint\":\"/user\",\"method\":\"GET\"}"
112 + -d "{\"user_id\":\"$OWNER_ID\",\"connected_account_id\":\"$CONNECTED_ACCOUNT_ID\",\"endpoint\":\"/user\",\"method\":\"GET\"}"
113 ```
114 </Tab>
115 </Tabs>
116
114 -Open the printed Connect Link and authorize GitHub within 60 seconds. The connection must become `ACTIVE` before the proxy request runs. The proxy returns the provider's response, not its OAuth token. No tool schemas are fetched and no model selects an action.
117 +Open the printed Connect Link and authorize GitHub within 60 seconds. The connection must become `ACTIVE` before the proxy request runs. During this wait, `INACTIVE` can still become `ACTIVE`, so keep polling until the deadline. Stop immediately on `FAILED`, `EXPIRED`, or `REVOKED`. The proxy returns the provider's response, not its OAuth token. No tool schemas are fetched and no model selects an action.
118
116 -The session above provides a user-scoped context for creating the connection. The final request uses the exact returned connected-account ID, so another GitHub connection cannot be selected accidentally. Your own tool can call `read_github_profile()` or `readGitHubProfile()` from any framework, or you can make the equivalent REST request from your backend.
119 +The session above provides a user-scoped context for creating the connection. The direct proxy call is independent of that session: pass both the owner (`user_id` in Python and REST, `userId` in TypeScript) and the exact returned connected-account ID. Projects with 2FA enabled check the owner against the connected account and may require it. Your own tool can call `read_github_profile()` or `readGitHubProfile()` from any framework, or you can make the equivalent REST request from your backend.
120
121 ## Reuse connections in your application
122