OAuth 2.1 and PKCE
Furnace is an OAuth 2.1 authorization server for its own API and MCP server. It supports one flow: the authorization-code grant with PKCE (S256), for public clients that register themselves. There are no client secrets; PKCE is the proof that the client exchanging a code is the one that asked for it. The token a client receives is a personal access token underneath, so it passes the same checks as any other bearer token.
Authorization code with PKCE: 7 nodes and 7 connections at L2 Containers.
- OAuth client (actor)
- Discovery documents (service)
- POST /oauth/register (service)
- GET /oauth/authorize (service)
- Consent page (service)
- POST /oauth/token (service)
- Personal access tokens (store)
- OAuth client connects to Discovery documents (sync, Discover)
- OAuth client connects to POST /oauth/register (sync, Register)
- OAuth client connects to GET /oauth/authorize (sync, Browser redirect)
- GET /oauth/authorize connects to Consent page (sync, Redirect)
- Consent page connects to OAuth client (feedback, code)
- OAuth client connects to POST /oauth/token (sync, Exchange)
- POST /oauth/token connects to Personal access tokens (sync, Mint)
Discovery
A request to the MCP server without a valid token answers 401 with a challenge pointing at the protected-resource document:
WWW-Authenticate: Bearer realm="furnace", resource_metadata="https://api.falcata.io/.well-known/oauth-protected-resource"
GET /.well-known/oauth-protected-resource:
{
"resource": "https://api.falcata.io/mcp",
"authorization_servers": ["https://api.falcata.io"],
"bearer_methods_supported": ["header"],
"scopes_supported": ["full"]
}
GET /.well-known/oauth-authorization-server:
{
"issuer": "https://api.falcata.io",
"authorization_endpoint": "https://api.falcata.io/oauth/authorize",
"token_endpoint": "https://api.falcata.io/oauth/token",
"registration_endpoint": "https://api.falcata.io/oauth/register",
"response_types_supported": ["code"],
"grant_types_supported": ["authorization_code"],
"code_challenge_methods_supported": ["S256"],
"token_endpoint_auth_methods_supported": ["none"],
"authorization_response_iss_parameter_supported": true,
"scopes_supported": ["full"]
}
Dynamic client registration
POST /oauth/register with a JSON body:
{ "client_name": "My agent", "redirect_uris": ["https://example.com/callback"] }
| Field | Rule |
|---|---|
client_name | 1 to 200 characters. If missing, a client_id string in the body is used as the name, else Unnamed client. |
redirect_uris | At least one. Each must be https, or http on localhost or the IPv4 loopback address for local clients. |
A valid registration answers 201:
{
"client_id": "fclient_...",
"client_name": "My agent",
"redirect_uris": ["https://example.com/callback"],
"token_endpoint_auth_method": "none",
"grant_types": ["authorization_code"],
"response_types": ["code"],
"client_id_issued_at": 1764547200
}
An invalid one answers 400 with { "error": "invalid_client_metadata", "error_description": "..." }.
Authorization request
Send the person's browser to GET /oauth/authorize with:
| Parameter | Required | Value |
|---|---|---|
response_type | yes | code |
client_id | yes | From registration |
redirect_uri | yes | Exactly one of the registered URIs |
code_challenge | yes | Base64url SHA-256 of your code verifier |
code_challenge_method | yes | S256 |
scope | no | full, the only scope; it is the default |
state | no | Returned to you unchanged |
resource | no | https://api.falcata.io/mcp or https://api.falcata.io (RFC 8707); both mean the MCP resource |
Errors are reported in two ways, as RFC 6749 requires:
- A missing or unknown
client_id, or aredirect_urithat is missing or not registered, shows an error page in the browser. The server never redirects to a URI it has not verified. - Any other problem redirects back to your
redirect_uriwitherror,error_description,issand yourstate. The codes areunsupported_response_type,invalid_request(missing PKCE or a method other thanS256),invalid_scopeandinvalid_target(an unrecognisedresource).
A valid request is stored and the browser is redirected to the Falcata ID consent page. The person signs in if needed, sees your client's name, and approves or denies. The pending request expires after ten minutes.
The redirect back
On approval the browser returns to your redirect_uri with:
https://example.com/callback?code=...&iss=https://api.falcata.io&state=...
On denial it carries error=access_denied, iss and state instead. Check that iss is https://api.falcata.io and that state is yours.
The code is single-use and expires ten minutes after approval. The server stores only a hash of it.
Token exchange
POST /oauth/token with application/x-www-form-urlencoded or JSON:
| Parameter | Value |
|---|---|
grant_type | authorization_code |
code | The code from the redirect |
client_id | The same client |
redirect_uri | The same URI as in the authorization request |
code_verifier | The verifier behind your challenge, 43 to 128 characters |
resource | Optional; if both requests name a resource, they must match |
A successful exchange returns:
{ "access_token": "fpat_...", "token_type": "Bearer", "scope": "full" }
There is no refresh token and no expires_in. Send the token as Authorization: Bearer <access_token> to the REST API or the MCP server.
| Error | When |
|---|---|
unsupported_grant_type | grant_type is not authorization_code |
invalid_request | A required parameter is missing, the body is not valid JSON, or the content type is neither form nor JSON |
invalid_grant | The code is unknown, already used or expired; the client or redirect URI does not match; or the verifier fails PKCE |
invalid_target | The resource is unrecognised or differs from the one authorised |
Every error is a 400 with error and error_description. A code is marked used before the token is minted, so replaying it, even concurrently, gets invalid_grant.
What the token is
The access token is a personal access token for the person who approved, labelled OAuth: <client name>. It resolves to that person on every call and passes the same API access and permission checks as any token, so it can never do more than they can. Revoke it as you would any personal access token.