Skip to main content

Launch: −50% for 3 months with LANSARE50

Pricing →

OAuth 2.1 (MCP)

How MCP clients sign in without an API key: discovery, PKCE, consent, tokens.

Mform is its own OAuth 2.1 authorization server for one protected resource: the MCP endpoint https://forms.megapromoting.com/api/mcp. Claude, ChatGPT, Claude Code and Cursor run this flow for you; this page is for people building their own MCP client.

Discovery

  • A request to the MCP endpoint without a token answers 401 with WWW-Authenticate: Bearer resource_metadata="…/.well-known/oauth-protected-resource/api/mcp", scope="…".
  • Protected resource metadata (RFC 9728) names the resource and the authorization server.
  • Authorization server metadata (RFC 8414) lists the endpoints: /oauth/authorize, /api/oauth/token, /api/oauth/register, /api/oauth/revoke.
# 1. The 401 from https://forms.megapromoting.com/api/mcp points here (WWW-Authenticate: resource_metadata=…)
curl https://mform.md/.well-known/oauth-protected-resource/api/mcp
# 2. Authorization server metadata (endpoints, PKCE S256, scopes)
curl https://mform.md/.well-known/oauth-authorization-server

Clients

  • Client ID Metadata Documents: the client_id is an https URL (port 443) that serves the client's JSON metadata; we fetch it without redirects, at most 5 KB, and cache it 5 minutes to 24 hours.
  • Dynamic Client Registration (RFC 7591) at /api/oauth/register.
  • Redirect URIs: https, or http on localhost / 127.0.0.1 / [::1] (any port) for native apps; no fragments; 1–10 per client.
  • Token endpoint authentication: none (public clients), client_secret_post or client_secret_basic.

Authorization code with PKCE

  • response_type=code; PKCE with code_challenge_method=S256 is required.
  • resource must be the resource from the protected resource metadata (the MCP URL); tokens are bound to it.
  • Scopes you may request: forms:read responses:read workspace:read forms:write ai:summarize responses:pii responses:delete offline_access. files:read and webhooks:manage are never granted to MCP.
  • On the consent page the person picks the workspace, the access level (capped by their role and by the workspace's highest level for agents), the forms and — only if the admin allows it — personal data.
  • The authorization code is valid 60 seconds and works once; reusing it revokes the connection it created.
# Authorization request (browser): PKCE S256 and resource are required
GET https://mform.md/oauth/authorize?response_type=code&client_id=<client_id>
    &redirect_uri=<redirect_uri>&code_challenge=<S256 challenge>&code_challenge_method=S256
    &resource=https%3A%2F%2Fforms.megapromoting.com%2Fapi%2Fmcp&scope=forms:read%20responses:read%20offline_access&state=<state>

# Code exchange (code valid 60 seconds, single use)
POST https://mform.md/api/oauth/token
Content-Type: application/x-www-form-urlencoded

grant_type=authorization_code&code=<code>&redirect_uri=<redirect_uri>&client_id=<client_id>
&code_verifier=<verifier>&resource=https%3A%2F%2Fforms.megapromoting.com%2Fapi%2Fmcp

# → { "access_token": "mfo_…", "token_type": "Bearer", "expires_in": 3600, "refresh_token": "mfr_…", "scope": "…" }

# Refresh (the refresh token rotates on every use)
POST https://mform.md/api/oauth/token
grant_type=refresh_token&refresh_token=mfr_…&client_id=<client_id>&resource=https%3A%2F%2Fforms.megapromoting.com%2Fapi%2Fmcp

Tokens

  • Access token mfo_… valid 1 hour, accepted only on the MCP endpoint.
  • Refresh token mfr_… valid 30 days, sliding; it rotates on every use. Reusing an old refresh token revokes the whole connection.
  • Revoke with POST /api/oauth/revoke, or in Settings → Developers → Activity → Connected apps.
  • Like API keys, a connection follows the person's current role and the workspace policies on every call.
  • The token endpoint allows 30 requests per minute per IP.