# Fimo authentication

Fimo's Project MCP resource uses OAuth authorization code with PKCE S256. See the [MCP guide](https://fimo.ai/docs/ai/mcp) for client setup and available tools.

## Discover

- Resource: `https://api.fimo.ai/api/mcp`
- Protected-resource metadata: `https://api.fimo.ai/.well-known/oauth-protected-resource/api/mcp`
- Authorization-server metadata: `https://api.fimo.ai/.well-known/oauth-authorization-server`

An unauthenticated request to the resource returns a `401` Bearer challenge whose `resource_metadata` value points to the protected-resource metadata.

## Pick a method

Use the authorization-code flow with PKCE S256 for interactive clients. Fimo also supports refresh-token grants when `offline_access` is approved. Client credentials, device-code grants, and agent-specific identity assertions are not supported.

## Register

Register clients dynamically at `https://api.fimo.ai/api/auth/oauth2/register`. Public clients are supported. Register the exact redirect URI, use `authorization_code`, and use `none` as the token endpoint authentication method when the client cannot keep a secret.

## Authorize

Send the user to `https://api.fimo.ai/api/auth/oauth2/authorize` with `response_type=code`, the registered `client_id` and `redirect_uri`, a random `state`, and PKCE `code_challenge_method=S256`. Include the RFC 8707 resource indicator `resource=https://api.fimo.ai/api/mcp`. Fimo always asks the signed-in user for consent.

Supported scopes are exactly `openid`, `profile`, `email`, `offline_access`, `read`, `write`, and `agents`. The Fimo access scopes allow read tools, mutation tools, and `agents_run` respectively. Request `offline_access` when a refresh token is needed.

## Claim

There is no separate credential-claim endpoint. The signed-in user grants access by approving scopes on Fimo's consent screen. The resulting credential is bound to that user and the Project MCP resource.

## Exchange

POST form-encoded authorization-code or refresh-token grants to `https://api.fimo.ai/api/auth/oauth2/token`. For an authorization code, include `code`, `client_id`, `redirect_uri`, `code_verifier`, and `resource=https://api.fimo.ai/api/mcp`.

Access tokens expire after 1 hour. Refresh tokens expire after 7 days. OAuth access tokens are rejected at the MCP resource whenever their user no longer exists or is banned.

## Use credential

Send `Authorization: Bearer <access_token>` on `POST https://api.fimo.ai/api/mcp`. The OAuth access token is accepted only by this MCP resource, not by other Fimo API routes. The transport is stateless and does not issue an `Mcp-Session-Id`.

## Errors

- `401`: the Bearer token is missing, malformed, invalid, expired, or belongs to an unavailable user. Follow the `resource_metadata` challenge.
- `invalid_target`: the RFC 8707 resource does not match `https://api.fimo.ai/api/mcp`.
- `invalid_scope` or `insufficient_scope`: the requested or granted scopes do not permit the operation.
- `405`: a valid credential used a method other than POST. Retry with POST.
- `413`: the request body exceeds 2 MB.

## Revocation

There is currently no client-initiated token revocation endpoint. Clients should discard local credentials when disconnecting and must not present an access token after it expires.
