Start an OAuth authorization flow and store the resulting MCP credential in a vault.
POST /api/v1/cloud/oauth/start
Starts an OAuth authorization flow for an MCP server. CAS discovers the server's OAuth metadata, prepares PKCE, and returns the provider authorization URL. After the provider redirects to the CAS callback, CAS exchanges the authorization code and stores an mcp_oauth credential in the selected Vault.
Headers
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer $QODER_ACCESS_TOKEN |
Content-Type | Yes | application/json |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
vault_id | string | Yes | Active Vault in which CAS will store the resulting credential |
mcp_server_url | string | Yes | MCP server URL used for OAuth metadata discovery and later credential matching |
client_id | string | No | Pre-registered OAuth client ID. If omitted, CAS uses dynamic client registration when the authorization server advertises it |
client_secret | string | No | Secret for the supplied client_id. Provide these two fields together for a confidential client |
protocol, scope, and redirect_uri are not request fields. CAS discovers the OAuth endpoints and scopes from server metadata and always uses its configured callback URL.
Example request
Example response
HTTP 200 OK
| Field | Type | Description |
|---|---|---|
authorization_url | string | Provider URL to open in a browser |
state | string | Opaque, short-lived OAuth state. Use it only to correlate the popup callback |
callback_origin | string | Origin from which the browser callback message is expected |
Complete the authorization
- Open
authorization_urlin a browser window. - The user approves access at the OAuth provider.
- The provider redirects to the callback URL embedded by CAS. The callback URL is service-configured and cannot be overridden by this request.
- CAS validates and consumes the one-time state, exchanges the code for tokens, and creates an
mcp_oauthcredential invault_id. - The callback page sends an
oauth_callbackmessage to its opener. You can also list the Vault's credentials to retrieve the new credential ID; secret values are never returned.
S256. When no client_id is supplied and the provider advertises a registration endpoint, CAS dynamically registers a public OAuth client.
Browser redirect shortcut
GET /api/v1/cloud/oauth/authorize accepts vault_id, mcp_server_url, and client_id as query parameters, starts the same flow, and responds with an HTTP redirect to the provider. Use POST /oauth/start when a client secret is required; do not place secrets in a URL.
Errors
| HTTP | Type | Trigger |
|---|---|---|
| 400 | invalid_request_error | Required field missing, Vault inactive, metadata discovery or dynamic registration failed, or the provider does not support required PKCE/token authentication behavior |
| 401 | authentication_error | PAT or SAT missing, invalid, or expired |
| 404 | not_found_error | Vault does not exist or is not accessible |
| 409 | conflict_error | Vault is not active, or an active credential for the MCP URL already exists when the callback stores the credential |