# Source OAuth Authenticate sources using OAuth flows. ## Initiate native OAuth Start the native OAuth flow for a source that supports it. #### Request Body **`source_definition_id`** string required The source definition ID. **`workspace_id`** string required The workspace ID. **`redirect_url`** string required URL to redirect to after OAuth completion. **`o_auth_input_configuration`** object optional Additional OAuth input configuration. ## Initiate connector OAuth Start an OAuth flow through the Aitronos connector platform. #### Request Body **`slug`** string required The connector app slug (e.g., `google-sheets`, `github`). **`redirect_url`** string required URL to redirect to after OAuth completion. ## Complete connector OAuth callback Complete the connector OAuth flow and create a source with the obtained credentials. #### Request Body **`connection_id`** string required The connection ID from the OAuth initiation. **`workspace_id`** string required The workspace to create the source in. **`source_definition_id`** string required The source definition to use. **`source_name`** string required Display name for the new source. ## Returns For native OAuth: an object with the consent URL. For connector OAuth authorize: `authorization_url` and `connection_id`. For callback: the created source object. Request ```bash cURL curl -X POST "https://api.aitronos.com/v1/organizations/org_xyz789/knowledge/connectors/sources/authorize" \ -H "Authorization: Bearer $ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d '{"slug": "google-sheets", "redirect_url": "https://app.example.com/callback"}' ``` ```python Python SDK from aitronos import Aitronos client = Aitronos(api_key="your-api-key") result = client.knowledge_connectors.authorize_source( organization_id="org_xyz789", slug="google-sheets", redirect_url="https://app.example.com/callback", ) print(result) ``` ```python Python import requests org_id = "org_xyz789" url = f"https://api.aitronos.com/v1/organizations/{org_id}/knowledge/connectors/sources/authorize" headers = { "Authorization": "Bearer YOUR_ACCESS_TOKEN", "Content-Type": "application/json", } data = { "slug": "google-sheets", "redirect_url": "https://app.example.com/callback", } response = requests.post(url, headers=headers, json=data) print(response.json()) ``` ```javascript JavaScript const response = await fetch( "https://api.aitronos.com/v1/organizations/org_xyz789/knowledge/connectors/sources/authorize", { method: "POST", headers: { Authorization: "Bearer YOUR_ACCESS_TOKEN", "Content-Type": "application/json", }, body: JSON.stringify({ slug: "google-sheets", redirect_url: "https://app.example.com/callback", }), } ); const data = await response.json(); console.log(data); ``` Response ```json 200 OK — Authorize { "authorization_url": "https://accounts.google.com/o/oauth2/auth?...", "connection_id": "conn_abc123" } ``` ```json 4xx Error { "success": false, "error": { "code": "CONNECTOR_OAUTH_FAILED", "message": "OAuth authentication failed.", "type": "server_error", "status": 500, "details": {}, "trace_id": "abc-123-def", "timestamp": "2025-12-22T15:30:00Z" } } ``` ## Related Resources - [Sources](/docs/api-reference/knowledge-connectors/sources) - [Source Testing](/docs/api-reference/knowledge-connectors/source-testing) - [Workspaces](/docs/api-reference/knowledge-connectors/workspaces)