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.
Login clients: people sign in
Section titled “Login clients: people sign in”For an application people use themselves — a custom portal, an admin tool.
- Send the browser to
/oauth/authorizewithresponse_type=code,client_id, a registeredredirect_uri,state, a PKCEcode_challengewithcode_challenge_method=S256, andscope:cs.content, pluscs.adminif the client has admin access and the user should administer. - 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.
- The browser comes back to your
redirect_uriwithcodeandstate. - Redeem the code at
/oauth/token, form-encoded:grant_type=authorization_code,code,redirect_uri,client_id,code_verifier. You get anaccess_token(15 minutes) and arefresh_token. - 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.
Impersonating clients: act for users
Section titled “Impersonating clients: act for users”For a server that searches on behalf of its own users — an intranet, an assistant — without them signing in to ContentSurface.
POST /oauth/tokenAuthorization: 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.
AI applications: MCP clients
Section titled “AI applications: MCP clients”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_idis the HTTPS address of its client ID metadata document: a JSON object withclient_id(that same address),client_nameandredirect_uris. ContentSurface fetches it from a public address and caches it; theredirect_urimust be one it lists, exactly. There is no dynamic client registration. - Discovery:
/mcpanswers401with aresource_metadataaddress; that document names the authorization server of the table above, whose metadata saysclient_id_metadata_document_supportedandauthorization_response_iss_parameter_supported. - Sign-in is the flow above with
resourcethe MCP address andscope=cs.content, started at the authorization server’s/oauth/authorize. Throughhttps://auth.contentsurface.iothe person first names their workspace and is then sent to the workspace’s sign-in; the response comes back withiss=https://auth.contentsurface.io. The person confirms on a consent page. Redeem the code and refresh at the same authorization server’s/oauth/tokenwith the sameclient_idand 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
/v1endpoints refuse it, the other kind of MCP address refuses it, and/mcprefuses every other token. It carriescs.contentonly, 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.
Checking tokens yourself
Section titled “Checking tokens yourself”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.
Errors
Section titled “Errors”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.