# Complete OAuth Complete a personal connector OAuth flow by finalizing the authorization with a state token. Finalize the OAuth authorization flow for a personal connector using the state token from the authorization step. This is used for connectors that require an explicit completion step separate from the OAuth callback. #### Query Parameters **`organization_id`** string required The unique identifier of the organization to associate the connector with. #### Request Body **`state_token`** string required The state token returned from the OAuth authorization flow, used to verify and complete the connection. ## Returns Returns the connector connection status and details. Request ```bash cURL curl -X POST "https://api.aitronos.com/v1/personal-connectors/complete-oauth?organization_id=org_abc123" \ -H "X-API-Key: $FREDDY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "state_token": "state_xyz789abc" }' ``` ```python Python import os import requests api_key = os.environ["FREDDY_API_KEY"] organization_id = "org_abc123" response = requests.post( "https://api.aitronos.com/v1/personal-connectors/complete-oauth", headers={"X-API-Key": api_key}, params={"organization_id": organization_id}, json={"state_token": "state_xyz789abc"} ) result = response.json() print(f"Connected: {result['connected']}") print(f"Message: {result['message']}") ``` ```javascript JavaScript const apiKey = process.env.FREDDY_API_KEY; const organizationId = "org_abc123"; const response = await fetch( `https://api.aitronos.com/v1/personal-connectors/complete-oauth?organization_id=${organizationId}`, { method: "POST", headers: { "X-API-Key": apiKey, "Content-Type": "application/json", }, body: JSON.stringify({ state_token: "state_xyz789abc", }), } ); const result = await response.json(); console.log(`Connected: ${result.connected}`); console.log(`Message: ${result.message}`); ``` Response ```json 200 OK { "connected": true, "connection": { "id": "conn_abc123", "app_key": "github", "status": "active" }, "message": "OAuth flow completed successfully" } ``` ```json 401 Unauthorized { "success": false, "error": { "code": "AUTHENTICATION_REQUIRED", "message": "Authentication required. Please provide a valid API key.", "system_message": "Authentication required. Please provide a valid API key.", "type": "authentication_error", "status": 401, "details": {}, "trace_id": "req_abc123xyz", "timestamp": "2025-12-22T15:30:00Z" } } ``` ```json 400 Bad Request { "success": false, "error": { "code": "VALIDATION_ERROR", "message": "The request contains invalid parameters.", "system_message": "Invalid or expired state token.", "type": "validation_error", "status": 400, "details": {}, "trace_id": "req_abc123xyz", "timestamp": "2025-12-22T15:30:00Z" } } ``` ## Related Resources - [Authorize Connector](/docs/api-reference/toolbox/personal-connectors/authorize) - [OAuth Callback](/docs/api-reference/toolbox/personal-connectors/callback) - [List Personal Connectors](/docs/api-reference/toolbox/personal-connectors/list) - [Delete Personal Connector](/docs/api-reference/toolbox/personal-connectors/delete)