Skip to content

OAuth tokens and delegated access ​

OAuth lets an application use the access a person has granted it. This reference covers token exchange, refresh, revocation, and profile reads for an existing configured OAuth client.

For a new remote MCP connection, follow MCP setup. For the Chainabit CLI, use CLI login. For an ordinary interactive API request, use authentication.

Supported operations ​

MethodPathPurpose
POST/oauth/tokenExchange an authorization code or refresh an existing grant
POST/oauth/revokeRevoke a token
GET/oauth/userinfoRead the profile fields permitted by the grant

These paths are relative to https://api.chainabit.com/api/v1. OAuth token responses follow their OAuth response shape rather than the normal data envelope.

Scopes ​

ScopeWhat it grants
execution:runTrigger AI executions on the user's behalf
wallet:readRead the user's Chainabit wallet balance
projects:readList and read the user's Projects (Chainies)
bits:readRead Bits, including tree, calendar and Project Gantt views
bits:writeCreate and update Bits, including placing a Bit in a Chain, completing it and assigning people to it; deleting and executing are not included

Request only the scopes your application actually needs. Each scope is checked on its own: bits:write does not include bits:read.

Workspace ​

Requests made with projects:read, bits:read or bits:write act in a workspace of the account the user approved the application for. By default that is the user's workspace in that account; send an x-workspace-id header to choose another workspace the user can access in the same account. A workspace outside that account, or one the user cannot access, is refused with 403. An Organization that requires single sign-on refuses these requests with 403 and the error code SSO_REQUIRED.

Before exchanging a code ​

Your client must already be registered, with a matching redirect URI and the scopes it may request. Complete the configured browser consent flow first. Store the original PKCE verifier securely and validate the callback's state before accepting its authorization code.

This page does not provide a self-service client-registration API or a general-purpose authorization-server discovery setup. Use the configured integration's connection flow. Earlier direct setup examples are no longer maintained here.

Exchange a code ​

For a public client, provide its client ID and the verifier associated with the code. Set these values from your own configured integration:

curl --fail-with-body -sS -X POST "https://api.chainabit.com/api/v1/oauth/token" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode "grant_type=authorization_code" \
  --data-urlencode "client_id=$OAUTH_CLIENT_ID" \
  --data-urlencode "code=$AUTHORIZATION_CODE" \
  --data-urlencode "redirect_uri=$REDIRECT_URI" \
  --data-urlencode "code_verifier=$CODE_VERIFIER"

Confidential clients also authenticate using their configured client credentials. Do not put a client secret into a public browser application.

A successful token response includes access_token, token_type, expires_in, refresh_token, and the granted scope. Read expiry from the response instead of hardcoding a lifetime.

Use the granted access ​

Send the returned access token as a Bearer token only to operations that accept its granted scopes. Consent and token issuance do not make it equivalent to an unrestricted interactive session.

Refresh the grant ​

curl --fail-with-body -sS -X POST "https://api.chainabit.com/api/v1/oauth/token" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode "grant_type=refresh_token" \
  --data-urlencode "client_id=$OAUTH_CLIENT_ID" \
  --data-urlencode "refresh_token=$REFRESH_TOKEN"

Store the returned token values securely and replace the consumed refresh token. Do not issue concurrent refreshes with the same token or retry a consumed token as though it were a new grant.

Revoke a token ​

curl --fail-with-body -sS -X POST "https://api.chainabit.com/api/v1/oauth/revoke" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode "client_id=$OAUTH_CLIENT_ID" \
  --data-urlencode "token=$OAUTH_TOKEN" \
  --data-urlencode "token_type_hint=refresh_token"

Confidential clients must also provide their configured authentication. Revocation returns 200 OK for a valid revocation request even when the token is unknown; it does not confirm that a particular token existed.

Read the granted profile ​

curl --fail-with-body -sS "https://api.chainabit.com/api/v1/oauth/userinfo" \
  -H "Authorization: Bearer $OAUTH_ACCESS_TOKEN"

The response always identifies the subject with sub. Email fields require email:read; profile fields require profile:read. Do not assume those optional fields are always present.

Handle errors ​

ErrorCheck
invalid_clientClient identity and required client authentication
invalid_grantCode or refresh-token validity, redirect URI, and PKCE verifier
invalid_requestRequired fields and request encoding
unsupported_grant_typeUse the grant type supported by your configured integration

Protect the grant ​

Keep codes, verifiers, tokens, and client secrets out of logs and source control. Validate callback state, request only necessary scopes, and revoke access when the user disconnects.

For a new integration, begin with developer access or MCP setup according to the client you are building.

Built with purpose. chainabit.com