Start free

Help center / Developers and AI agents

OAuth 2.1 with PKCE

Issue short-lived, site-bound tokens to your own integration instead of sharing a key.

Custom integrations can obtain short-lived tokens for the MCP endpoint using the authorization code flow with PKCE (S256 only). Endpoints are listed at /.well-known/oauth-authorization-server.

Good to know
The authorization step is an API call made with the signed-in owner's session, and it returns the code in the response. It is not a hosted consent screen that redirects the browser. If your client expects one, connect it with an API key instead.

The flow

  1. Create a random code_verifier (43 to 128 characters) and its SHA-256 challenge, base64url encoded.
  2. As a signed-in user who can manage the site's settings, call POST /api/oauth/authorize with site, clientId, redirectUri, codeChallenge and either preset or scopes.
  3. Exchange the code at POST /api/oauth/token within 5 minutes. Each code works once.
  4. Send the access token to /api/mcp as Authorization: Bearer.
POST https://xigzag.com/api/oauth/token
Content-Type: application/json

{
  "grant_type": "authorization_code",
  "code": "<code>",
  "client_id": "my-integration",
  "redirect_uri": "https://example.com/callback",
  "code_verifier": "<verifier>"
}

The preset ids are read_only, content_editor, store_manager and full_draft. The token endpoint expects a JSON body.

Token lifetime and refresh

  • Access tokens last 1 hour.
  • To refresh, send grant_type set to refresh_token, with refresh_token. You get a new pair and the old pair stops working.
  • The owner can revoke all OAuth tokens for a site with POST /api/oauth/revoke.
  • If a refresh is refused, run the authorization flow again. Build your integration to handle this.

Use OAuth tokens with the MCP endpoint. For the REST API, use an API key.

Related articles

Still need help?
Open a support ticket or write to hello@xigzag.com.