Skip to content

OAuth and tokens

Who can do this: integrators; client applications are registered by tenant admins and user admins.

ContentSurface is its own OAuth 2.0 authorization server, one per tenant, at https://{slug}.contentsurface.io — and, for AI applications that connect through the MCP address for every workspace, one in front of them all at https://auth.contentsurface.io (see AI applications below). Every token names a user. There are two ways to get one, matching the two kinds of client application.

For an application people use themselves — a custom portal, an admin tool.

  1. Send the browser to /oauth/authorize with response_type=code, client_id, a registered redirect_uri, state, a PKCE code_challenge with code_challenge_method=S256, and scope: cs.content, plus cs.admin if the client has admin access and the user should administer.
  2. The person signs in on the tenant’s sign-in page — a one-time code by email, or Microsoft or Google where the tenant allows it.
  3. The browser comes back to your redirect_uri with code and state.
  4. Redeem the code at /oauth/token, form-encoded: grant_type=authorization_code, code, redirect_uri, client_id, code_verifier. You get an access_token (15 minutes) and a refresh_token.
  5. Refresh with grant_type=refresh_token. Each refresh token is used once and replaced. A session lasts while it is refreshed at least every 30 days; one started with Microsoft or Google ends after the tenant’s federated session lifetime.

Login clients have no secret: PKCE protects the code. Sign out with POST /oauth/logout; it ends the browser’s sign-in session. To end every session of the user, call POST /v1/me/sign-out-everywhere.

For a server that searches on behalf of its own users — an intranet, an assistant — without them signing in to ContentSurface.

POST /oauth/token
Authorization: Basic base64(client_id:secret)
Content-Type: application/x-www-form-urlencoded
grant_type=urn:ietf:params:oauth:grant-type:token-exchange
&subject_token=usr_…
&subject_token_type=urn:contentsurface:token-type:user-id
&scope=cs.content
  • The client must be related to the user, directly or through a group; otherwise invalid_grant.
  • The token reaches content only, with the user’s labels — never their admin roles.
  • Map your own users to ContentSurface user IDs once, for example with GET /v1/admin/users?text=… by email.
  • Cache the token for its lifetime rather than exchanging per request.

An AI application connecting to the MCP address is a third kind of client, and needs no registration. See AI applications (MCP). There are two kinds of MCP address, with one authorization server each:

MCP address Authorization server (issuer, iss)
https://mcp.contentsurface.io/mcp, for every workspace https://auth.contentsurface.io
https://{slug}.contentsurface.io/mcp, one workspace’s own https://{slug}.contentsurface.io
  • Its client_id is the HTTPS address of its client ID metadata document: a JSON object with client_id (that same address), client_name and redirect_uris. ContentSurface fetches it from a public address and caches it; the redirect_uri must be one it lists, exactly. There is no dynamic client registration.
  • Discovery: /mcp answers 401 with a resource_metadata address; that document names the authorization server of the table above, whose metadata says client_id_metadata_document_supported and authorization_response_iss_parameter_supported.
  • Sign-in is the flow above with resource the MCP address and scope=cs.content, started at the authorization server’s /oauth/authorize. Through https://auth.contentsurface.io the person first names their workspace and is then sent to the workspace’s sign-in; the response comes back with iss=https://auth.contentsurface.io. The person confirms on a consent page. Redeem the code and refresh at the same authorization server’s /oauth/token with the same client_id and no secret: a code or refresh token is redeemed only where it was issued.
  • The access token is for its MCP address only: the API’s /v1 endpoints refuse it, the other kind of MCP address refuses it, and /mcp refuses every other token. It carries cs.content only, and stops working at once when the person or a tenant admin withdraws the application’s access, or a tenant admin turns MCP access off.

Access tokens are JWTs signed with the keys at /.well-known/jwks.json. Treat them as opaque unless you must check them: ContentSurface checks every token on every call, including whether the user is still active.

The token endpoint answers OAuth errors: invalid_client (unknown client or wrong secret), invalid_grant (expired code, used refresh token, client not related, user not active), invalid_request, invalid_scope, unsupported_grant_type, and for an AI application invalid_target (a resource other than the MCP address of the authorization server) and, at https://auth.contentsurface.io, temporarily_unavailable (429 past the per-network limit, 503 while the workspace is being upgraded).

The sign-in page’s own steps, the workspace page of the global MCP address, the AI application consent page, the Microsoft and Google relay, and the connector consent callback appear in the reference for completeness; they are used by browsers, not called by applications.

In the API

The Portal does this through these calls; an integration can make them directly.

OperationCall
Authorization server metadata (RFC 8414) of the addressed tenant.GET /.well-known/oauth-authorization-server
The public token signing keys (JWKS).GET /.well-known/jwks.json
Authorization code + PKCE: sign in and redirect back with a code.GET /oauth/authorize
Token endpoint: authorization_code, refresh_token and token exchange (RFC 8693).POST /oauth/token
Ends this browser's login session; the Portal may name its redirect URI as post_logout_redirect_uri.POST /oauth/logout
Login page step 1: send a one-time code to an email address.POST /oauth/login
Login page step 2: verify the one-time code.POST /oauth/login/code
Federated sign-in step 1: redirect to Microsoft Entra ID or Google.POST /oauth/federated/{provider}
The providers' one redirect URI: forwards to the tenant address named in the state.GET /oauth/federated/callback
Federated sign-in step 2, on the tenant address: verify, match the user, sign in.GET /oauth/federated/complete
Entra ID's redirect after an admin consent: records the consenting organisation, from its validated ID token, in the connection.GET /oauth/connector-consent/callback
The consent page's answer for an AI application (MCP client); posted by the page itself.POST /oauth/mcp/consent
The global sign-in page's answer: the workspace an AI application connects to; posted by the page itself.POST /oauth/workspace
Protected resource metadata (RFC 9728) of the MCP endpoint: the global one or a tenant's.GET /.well-known/oauth-protected-resource/mcp