Custom integrations
For a user-facing OAuth client, use the Gumnut OAuth endpoints to start and complete the authorization-code flow:- Call
GET https://api.gumnut.ai/api/oauth/auth-urlwith your exactredirect_uriand, for public clients, a PKCEcode_challengepluscode_challenge_method=S256. - Redirect the user to the returned authorization URL.
- Read the
codeandstatefrom your callback URL. - Send them to
POST https://api.gumnut.ai/api/oauth/exchange, along with the PKCEcode_verifierwhen one was used. - Send the returned
access_tokenas a Bearer token on API requests.
state value tied to the user’s session, use PKCE for public clients,
and register redirect URIs exactly.
First-time provisioning
When a user completes OAuth for the first time, Gumnut verifies the current Clerk identity before creating the user’s local Gumnut account. Existing local users continue through the normal token-exchange flow. ThePOST /api/oauth/exchange response tells you how to recover when that
verification cannot complete:
These errors are returned only while Gumnut is provisioning a new local user;
they do not indicate that the authorization-code parameters are malformed.
MCP hosts
Connect an MCP host to:Discovery flow
-
The MCP host fetches Gumnut’s protected-resource metadata:
- That metadata identifies Clerk as the authorization server.
- The host fetches Clerk’s authorization-server metadata to discover the authorization, token, and supported client-registration endpoints.
-
The host completes the authorization-code flow with PKCE, manages the tokens,
and sends the access token in the
Authorizationheader on MCP requests.
MCP request authentication
The MCP transport itself is protected. After discovery, the host must send a valid bearer credential on every HTTP request, includinginitialize,
tools/list, notifications, resource requests, and tool calls. A missing,
invalid, expired, or revoked credential receives 401 Unauthorized with a
WWW-Authenticate challenge. Browser cookies are not accepted as a fallback
for MCP bearer authentication.
OAuth discovery metadata and CORS preflight requests are public. A valid
first-time Clerk bearer can complete discovery before a local Gumnut account
exists; the normal REST flow performs provisioning when the user uses a tool.
For MCP discovery, do not construct the provider’s authorization or token
endpoint URLs under
api.gumnut.ai. Gumnut does not publish
/oauth/authorize, /oauth/token, or /oauth/revoke endpoints; follow the
discovery metadata so the host uses Clerk’s current endpoints. The custom
integration endpoints documented above are separate Gumnut endpoints.Scopes
The protected-resource metadata currently advertises these identity and session scopes:profileemailoffline_access
Token handling for custom integrations
Theaccess_token returned by /api/oauth/exchange is a Gumnut JWT. There is
no refresh-token exchange in this flow. Replace your stored token whenever an
authenticated response includes an x-new-access-token header. If the token
expires before it can be refreshed, restart the authorization flow.
Token handling for MCP hosts
The MCP host owns token storage, refresh, and logout behavior. Follow the authorization server’s returned token metadata and let the host’s OAuth client manage renewal.Troubleshooting
The host does not open a sign-in or consent page
Confirm that the server URL is exactlyhttps://api.gumnut.ai/mcp and that the
host supports OAuth discovery for remote MCP servers. Do not configure guessed
Gumnut OAuth endpoints manually.