Authentication (OAuth 2.1)

How MCP clients authenticate to the RedERP MCP server: discovery documents, dynamic client registration, PKCE, scopes, token lifetimes, refresh and revocation.

The RedERP MCP server is an OAuth 2.1 protected resource and RedERP itself is the authorization server. Users always sign in on RedERP's consent page; assistants never see RedERP passwords.

Discovery

DocumentURL
Protected resource metadata (RFC 9728)https://rederp.ai/.well-known/oauth-protected-resource and https://rederp.ai/.well-known/oauth-protected-resource/mcp
Authorization server metadata (RFC 8414)https://rederp.ai/.well-known/oauth-authorization-server
OpenID Connect discoveryhttps://rederp.ai/.well-known/openid-configuration (same authorization server)
JWK Set (ID-token signatures)https://rederp.ai/oauth/jwks.json
Resource identifier (RFC 8707 resource)https://rederp.ai/mcp

An unauthenticated call to https://rederp.ai/mcp returns:

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer error="invalid_token", error_description="Missing Authorization header",
  resource_metadata="https://rederp.ai/.well-known/oauth-protected-resource/mcp"

Endpoints

EndpointURLNotes
Authorizationhttps://rederp.ai/oauth/authorizeRenders the RedERP login + consent page (GET or POST)
Tokenhttps://rederp.ai/oauth/tokenauthorization_code (PKCE S256 required) and refresh_token grants
Dynamic client registration (RFC 7591)https://rederp.ai/oauth/registerPublic (token_endpoint_auth_method: none) or confidential clients; secrets never expire
Revocation (RFC 7009)https://rederp.ai/oauth/revokeRevokes the whole grant (access + refresh token)
UserInfo (OpenID Connect)https://rederp.ai/oauth/userinfosub, email, email_verified: true, name of the linked user
JWKShttps://rederp.ai/oauth/jwks.jsonRSA public key(s) used to sign ID tokens (RS256)

Client authentication methods accepted at the token endpoint: none, client_secret_post, client_secret_basic.

OpenID Connect

RedERP is also an OpenID Connect provider for the MCP server. When a client requests the openid scope, the token response contains an ID token (RS256, iss https://rederp.ai, aud = client id, nonce echoed) with email / email_verified: true (scope email) and name (scope profile). The UserInfo endpoint returns the same claims. This is what lets ChatGPT Enterprise workspaces apply domain restrictions: the verified email domain of the RedERP user must match the workspace's verified domains before the plugin can be linked.

Client identification

Clients can identify themselves in two ways:

  • Client ID Metadata Documents (CIMD) — the client sends an https://… URL as client_id; RedERP fetches and validates the JSON document (ChatGPT uses this). Advertised with client_id_metadata_document_supported: true.
  • Dynamic client registrationPOST https://rederp.ai/oauth/register with redirect_uris, client_name, token_endpoint_auth_method, … returns a client_id (and a secret for confidential clients).

Redirect URIs must be HTTPS on the client's own domain or on an allow-listed host (chatgpt.com, platform.openai.com, claude.ai, cursor.com, …), or a loopback address (http://localhost:<port>) for native/developer tools such as MCP Inspector.

Scopes

ScopeGrants
sales:readAll read tools (clients, products, stock, documents, payments, statements, KPIs, PDF links)
sales:writeCreate clients / documents / lines, forward status changes, conversions, payments
openid, email, profileOpenID Connect identity claims (user id, verified email, name) — no ERP data

When a client requests no scope, all of them are granted after consent; identity-only requests (openid email) also receive the two sales:* scopes shown on the consent page. A refresh can narrow but never broaden the scope.

Tokens

TokenLifetimeNotes
Authorization code5 minutes, single useBound to the PKCE challenge, redirect URI and resource
Access token1 hourOpaque bearer token (rerp_at_…), audience https://rederp.ai/mcp; only its hash is stored
Refresh token30 daysOpaque (rerp_rt_…), rotated on every use; reusing an old refresh token revokes the whole grant

Tokens are bound to one user in one company. Revoking access (from the assistant or through /oauth/revoke) invalidates every token of that grant immediately. Expired records are purged automatically.

Sequence