graphlife Docs graphlife.app

Accounts and access

8. OAuth 2.1 for MCP clients

The server is its own OAuth 2.1 authorization server. It exists so that MCP clients which require OAuth, rather than a pasted API key, can connect to the MCP endpoint POST /v1/live/mcp. A person signs in on a consent page, chooses which of their graphs the client may reach and whether it may write, and the client receives an access token that behaves like an API key with that reach.

The consent page grants whole graphs: on a personal graph the resulting token sees every node of each approved graph (allNodes). Narrowing a connection to particular groups is done afterwards with PATCH /v1/oauth/grants/{id}. On an organisation graph the token is bounded by the approving person's role and groups (section 8.2).

Supported: the authorization-code grant with PKCE (S256 only), refresh tokens, dynamic client registration (RFC 7591), Client ID Metadata Documents, token revocation (RFC 7009), resource indicators (RFC 8707), protected-resource metadata (RFC 9728), authorization-server metadata (RFC 8414), and the iss authorization-response parameter (RFC 9207).

Not supported: client secrets (public clients only; token_endpoint_auth_method must be none), the client-credentials grant, the password grant, the implicit grant, token introspection, and private_key_jwt. There is no machine-to-machine OAuth grant; a server-side integration without a person at a browser should use an API key (section 7), which on an organisation graph can belong to a service account.

The server derives its own public origin (the issuer) from the request's Host header. The scheme is https, except for localhost and 127.0.0.1, or, when TRUST_PROXY=true, whatever X-Forwarded-Proto says. Your reverse proxy must therefore forward the original Host header.

8.1 Scopes#

Scope Meaning
graph:read The read tools on the approved graphs.
graph:write The read and write tools on the approved graphs.

The access level is chosen by the person on the consent page ("Read only" or "Read and add"). A scope parameter on the authorization request is not read. The granted scope is reported in the token response.

GET/.well-known/oauth-protected-resource#

Also served at /.well-known/oauth-protected-resource/v1/live/mcp. Public. Cache-Control: public, max-age=300.

{
  "resource": "https://graphlife.example.com/v1/live/mcp",
  "authorization_servers": ["https://graphlife.example.com"],
  "scopes_supported": ["graph:read", "graph:write"],
  "bearer_methods_supported": ["header"],
  "resource_documentation": "https://graphlife.example.com/legal/privacy-policy.html"
}

An unauthenticated call to POST /v1/live/mcp answers 401 with a WWW-Authenticate: Bearer header whose resource_metadata parameter points at this document, which is how an MCP client discovers the flow.

GET/.well-known/oauth-authorization-server#

Also served at /.well-known/openid-configuration (same document). Public.

{
  "issuer": "https://graphlife.example.com",
  "authorization_endpoint": "https://graphlife.example.com/oauth/authorize",
  "token_endpoint": "https://graphlife.example.com/oauth/token",
  "registration_endpoint": "https://graphlife.example.com/oauth/register",
  "revocation_endpoint": "https://graphlife.example.com/oauth/revoke",
  "scopes_supported": ["graph:read", "graph:write"],
  "response_types_supported": ["code"],
  "grant_types_supported": ["authorization_code", "refresh_token"],
  "code_challenge_methods_supported": ["S256"],
  "token_endpoint_auth_methods_supported": ["none"],
  "authorization_response_iss_parameter_supported": true,
  "client_id_metadata_document_supported": true
}

Note that the server is not an OpenID Connect provider: it issues no ID tokens and has no userinfo or JWKS endpoint. The openid-configuration path exists only because some clients look there for the OAuth metadata.

POST/oauth/register#

Registers a public client (RFC 7591). Public, rate limited.

Body field Type Required Meaning
redirect_uris array of strings yes Only the first 10 entries are read. Each must be an absolute URI without a fragment and either https, http on localhost / 127.0.0.1 / ::1, or a private-use scheme containing a dot (for example com.example.app:/callback). Unusable entries are dropped.
client_name string no Shown to the person on the consent page.
token_endpoint_auth_method string no Must be none if present.
curl -X POST https://graphlife.example.com/oauth/register \
  -H 'Content-Type: application/json' \
  -d '{"client_name":"Example Assistant","redirect_uris":["https://assistant.example.com/oauth/callback"]}'

Response: 201 Created

{
  "client_id": "glc_Qm9...",
  "client_id_issued_at": 1764201600,
  "redirect_uris": ["https://assistant.example.com/oauth/callback"],
  "token_endpoint_auth_method": "none",
  "grant_types": ["authorization_code", "refresh_token"],
  "response_types": ["code"],
  "client_name": "Example Assistant"
}
Status error When
400 invalid_redirect_uri No usable redirect URI.
400 invalid_client_metadata token_endpoint_auth_method other than none, or a body that is not valid JSON.
429 (standard format) rate_limited

Client ID Metadata Documents. Instead of registering, a client may use an https URL as its client_id. The server fetches that URL (an outbound HTTPS request with a 5-second connect timeout and a 64 KB size cap), reads redirect_uris and client_name from the JSON document, requires that the document's own client_id, if present, equals the URL, and caches the result. A deployment whose outbound traffic is blocked will not be able to serve clients that rely on this.

There is no API to list, update or delete registered clients.

GET/oauth/authorize#

Starts the flow in the person's browser. Public (the person signs in on the page).

Query parameter Required Meaning
client_id yes A registered glc_… id, or an https metadata-document URL.
redirect_uri yes Must exactly match one registered for the client.
response_type yes Must be code.
code_challenge yes PKCE challenge, at least 43 characters.
code_challenge_method yes Must be S256.
state no Returned unchanged on the redirect.
resource no The resource the token is for. For this server, https://graphlife.example.com/v1/live/mcp.

Response: an HTML sign-in page. If the request is invalid, an HTML error page is shown with status 400; the browser is not redirected, because the redirect URI could not be trusted.

The sign-in page requires JavaScript: it derives the password in the browser (section 6.2) so that the typed password is never sent. If SSO providers are configured, the page also offers a "Sign in with …" link for each.

POST/oauth/authorize#

The form target of the sign-in and consent pages. It is driven by the browser, not by API clients. In outline:

  1. Sign-in step. Email and derived password are checked. On success the consent page is shown, listing the person's personal hosted graphs and the graphs of the organisations they belong to.
  2. Decision step. The person ticks one or more graphs, chooses "Read only" or "Read and add", and allows or cancels.

On approval the browser is redirected (302) to redirect_uri with code, state (if one was sent) and iss. On cancel it is redirected with error=access_denied, state and iss.

HTML responses from this route use status 401 for a wrong email or password or an expired sign-in step, 400 for a missing selection or disabled JavaScript, 413 for an oversized form, and 429 when rate limited.

POST/oauth/token#

Exchanges a code or a refresh token for tokens. Public. Body: application/x-www-form-urlencoded.

Authorization-code grant:

Form field Required Meaning
grant_type yes authorization_code
code yes The code from the redirect.
code_verifier yes The PKCE verifier.
client_id yes The client the code was issued to.
redirect_uri no If sent, must equal the one used at authorization.
resource no If sent, must equal the one used at authorization.

Refresh grant:

Form field Required Meaning
grant_type yes refresh_token
refresh_token yes
client_id no If sent, must be the client the token belongs to.
curl -X POST https://graphlife.example.com/oauth/token \
  -d grant_type=authorization_code \
  -d code="$CODE" \
  -d code_verifier="$VERIFIER" \
  -d client_id="$CLIENT_ID" \
  -d redirect_uri=https://assistant.example.com/oauth/callback

Response: 200 OK, Cache-Control: no-store

{
  "access_token": "glo_...",
  "token_type": "Bearer",
  "expires_in": 2592000,
  "refresh_token": "glr_...",
  "scope": "graph:read"
}

Refresh tokens are single use: each refresh revokes the previous access and refresh token and returns a new pair. A refresh token has no expiry date of its own, so a connection can be refreshed after its access token has expired, for as long as it has not been revoked. An authorization code that is presented a second time is refused, and tokens already issued to that client for that person since the code was created are revoked. A failed exchange (wrong verifier, wrong redirect URI) does not consume the code, so the client may retry within the code's 5-minute lifetime.

Status error When
400 unsupported_grant_type grant_type is neither of the two above.
400 invalid_request A required field is missing, or the form is too large (over 64 KB).
400 invalid_grant Unknown, used or expired code; code issued to another client; redirect URI mismatch; PKCE verification failed; unknown refresh token; refresh token of another client.
400 invalid_target resource does not match the grant.
429 (standard format) rate_limited

POST/oauth/revoke#

Revokes a token (RFC 7009). Public (the token is the credential). Body: form-encoded, field token, holding either an access token or a refresh token.

Response: always 200 OK with {}, including for a token the server has never seen.

GET/v1/oauth/grants#

Lists the caller's active OAuth connections. Session. Not paginated.

{
  "grants": [
    {
      "id": "p1Qx...",
      "client": "Example Assistant",
      "graphIds": ["9a8b7c6d-5e4f-4a3b-2c1d-0e9f8a7b6c5d"],
      "scope": "graph:read",
      "canWrite": false,
      "allNodes": true,
      "groups": [],
      "createdAt": 1764201600,
      "lastUsedAt": 1764288000
    }
  ]
}

Each refresh creates a new grant row with a new id and revokes the previous one, so id values are not stable across refreshes.

PATCH/v1/oauth/grants/{id}#

Changes what an existing connection may reach, without the client having to reconnect. Session (the grant's own account). The change applies from the connection's next call.

Body field Type Meaning
graphIds array of strings Replaces the list of graphs. Each must be a graph the caller owns or reaches through an organisation.
canWrite boolean true grants the read and write tools; false the read tools only.
allNodes boolean true lets the connection see every node of the graphs it reaches.
groups array of group ids Restricts the connection to these groups. Sending groups without allNodes turns allNodes off.

Omitted fields keep their current value. Response: 200 OK with the full, updated grants list (same shape as the listing).

Status code When
400 invalid No such grant for this account; an empty graph list; a graph the caller cannot reach; or a result that would see nothing (allNodes false and no groups).
401 unauthorized No valid session.

DELETE/v1/oauth/grants/{id}#

Ends a connection. Session. Response: 200 OK with {"revoked": true}, or {"revoked": false} if there was no such active grant for this account.

8.2 OAuth tokens on organisation graphs#

An OAuth token that reaches an organisation graph is bounded, on every call, by the current role and groups of the person who approved it, exactly like an API key (section 7). A read-only consent stays read-only; a removed member's connection reaches nothing.