Skip to content

Access on Behalf of a User (OAuth)

When an application needs to call Whiskers agents on behalf of a specific person, an API key is the wrong tool: a key is a machine identity, it does not know the person and does not apply their permissions. This page describes the right tool: the person signs in to Whiskers and approves your application, the application receives a user token for that person and makes its calls with it.

Which one, when:

Situation Use
Server-to-server integration, no person behind it API key (Overview)
A customer application calling for its own users, who have no Whiskers account API key + subject declaration
An internal application or a personal script, the caller has a Whiskers account User token (this page)

A call made with a user token follows the same rules as that person's calls from the console: agent access lists, seat, user quota, audit trail. Your application can do nothing the person cannot.

Prerequisites

  • The person needs a Whiskers account and permission to run the agent.
  • The agent must be exposed (admin approval; same rule as for API keys).
  • For REST scopes (agent:invoke, agent:upload_document, agent:approve) the consenting person needs the personal_token:manage permission — the same permission as for personal access tokens (PAT): the administrator decides who signs in with scripts. Without it the consent page does not open and says why; if the permission is withdrawn later, the token stops on its next REST request. The mcp scope does not need it.
  • Your application must be able to open a browser or listen on a redirect address (web app, desktop app, a CLI listening on a local port).

1. Register your application

Once, server-side:

curl -X POST "$HOST/oauth/register" \
  -H "Content-Type: application/json" \
  -d '{
    "client_name": "Accounting Assistant",
    "redirect_uris": ["https://accounting.example.com/oauth/callback"]
  }'
{"client_id": "mcpc_...", "client_name": "Accounting Assistant", "redirect_uris": ["..."]}
  • Only the public client + PKCE profile is supported; there is no client secret.
  • redirect_uris: https://…, http://127.0.0.1:<port>/… for local development, or a custom scheme for desktop apps (myapp://callback). Script-running schemes (javascript:, data: …) are rejected.
  • The registration endpoint needs no authentication and has a per-IP hourly cap.

The server's endpoints and supported scopes are published at GET $HOST/.well-known/oauth-authorization-server.

Generate a PKCE pair (code_verifier random, code_challenge the base64url of its SHA-256) and send the browser to:

GET $HOST/oauth/authorize
  ?response_type=code
  &client_id=mcpc_...
  &redirect_uri=https://accounting.example.com/oauth/callback
  &code_challenge=<S256>
  &code_challenge_method=S256
  &scope=agent:invoke
  &state=<random>

Whiskers checks the session: without one it sends the person to the sign-in page and returns to the same address afterwards. Then the consent page appears: your application's name, the requested scopes and the address the person will be redirected to after consenting (the host of the registered redirect_uri) are listed, and the person chooses Allow or Deny. The address is shown because the application name is text the application chose.

Scopes

Scope What it allows
agent:invoke Running agents over REST (invoke) and reading run status
agent:upload_document Uploading temporary documents to an agent (documents)
agent:approve Deciding on runs waiting for approval (decision — Human-approved agents)
mcp Listing and running agents over MCP (MCP integration)

Separate several scopes with spaces (scope=agent:invoke agent:upload_document). An unknown scope is rejected with 400 invalid_scope. The token can do exactly what the consent page showed, nothing more: a token approved for mcp gets 403 oauth_scope_forbidden on REST.

3. Exchange the code for tokens

After approval the browser returns to your redirect_uri with ?code=…&state=…. Verify state, then exchange the code within five minutes:

curl -X POST "$HOST/oauth/token" \
  -d grant_type=authorization_code \
  -d client_id=mcpc_... \
  -d code=<code> \
  -d redirect_uri=https://accounting.example.com/oauth/callback \
  -d code_verifier=<verifier>
{
  "access_token": "mcat_...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "refresh_token": "mcrt_...",
  "scope": "agent:invoke"
}

The code is single-use. Store the tokens as secrets; the access token lives one hour, the refresh token 30 days, and the consent as a whole at most 90 days.

4. Call

curl -X POST "$HOST/api/public/v1/agents/<agent-slug>/invoke" \
  -H "Authorization: Bearer mcat_..." \
  -H "Content-Type: application/json" \
  -d '{"input_message": "Summarise this month's invoices"}'

Body and response are the same as with an API key (Invoking an agent). The differences:

  • The run starts as the person: agent access list, seat and user quota apply; the audit trail names the person as the actor.
  • invoke-async (webhook callback) is not available on this path (403 api_key_required); for long jobs send "async": true and poll the status endpoint.
  • The subject field is unnecessary and ignored: the identity is already real.
  • The rate limit is per user (see System limits).

5. Refreshing

When the access token expires, the request returns 401 oauth_token_invalid with a WWW-Authenticate header. Get a new pair with the refresh token:

curl -X POST "$HOST/oauth/token" \
  -d grant_type=refresh_token \
  -d client_id=mcpc_... \
  -d refresh_token=mcrt_...

The used refresh token becomes invalid immediately and a new one comes with the response (rotation). Never reuse the old one.

For scripts and CLIs: personal access token

Where a browser redirect is hard to obtain (a personal script, a CLI outside CI, Postman) use a personal access token (PAT) instead of the OAuth flow. A PAT is a user token too: same mcat_ format, same scopes, same rules (permissions, seat, quota, rate limit). The difference is how it is issued: a button in the console instead of a consent flow.

  1. In the console open Settings → Security → Personal access tokens. If the section is missing, your administrator has not granted you the personal_token:manage permission; the right to create PATs is off by default for non-administrator roles.
  2. Choose a name, scope(s) and an expiry date. Expiry is mandatory and at most 90 days ahead; there is no token without an expiry.
  3. The token is shown only once; copy it and keep it as a secret.
curl -X POST "$HOST/api/public/v1/agents/<agent-slug>/invoke" \
  -H "Authorization: Bearer $WHISKERS_PAT" \
  -H "Content-Type: application/json" \
  -d '{"input_message": "Summarise today's meeting notes"}'
  • There is no refresh: when a PAT expires, create a new one.
  • You can revoke it any time from the same section; when your account is disabled or you change your password, all your PATs are revoked as well.
  • A PAT is your identity: do not share it or embed it in an application. Use the OAuth flow (above) for applications and an API key for server-to-server.

When does a token die?

  • When the person is disabled, deleted or changes their password, all their tokens are revoked at once.
  • When the consent's absolute lifetime (90 days) runs out, refresh is refused too; restart the flow from step 2.
  • Every consent is asked separately; there is no "remember me".

Common pitfalls

  • 400 invalid_client / invalid_redirect_uri: unknown client_id, or the redirect_uri is not exactly the registered one. No redirect happens; the error is returned directly.
  • 400 invalid_request (PKCE): code_challenge missing or the method is not S256.
  • 401 login_required: the installation has no sign-in page configured; contact your Whiskers administrator.
  • 403 oauth_scope_forbidden: the token was not approved for this surface; ask for consent again with the right scope.
  • 403 oauth_rest_permission_required: the token carries a REST scope but its owner no longer has the personal_token:manage permission (an administrator withdrew it). The person should contact their administrator.
  • 402: the person has no seat or the installation's license has expired — an account problem, not your application's.