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
| Document | URL |
|---|---|
| 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 discovery | https://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
| Endpoint | URL | Notes |
|---|---|---|
| Authorization | https://rederp.ai/oauth/authorize | Renders the RedERP login + consent page (GET or POST) |
| Token | https://rederp.ai/oauth/token | authorization_code (PKCE S256 required) and refresh_token grants |
| Dynamic client registration (RFC 7591) | https://rederp.ai/oauth/register | Public (token_endpoint_auth_method: none) or confidential clients; secrets never expire |
| Revocation (RFC 7009) | https://rederp.ai/oauth/revoke | Revokes the whole grant (access + refresh token) |
| UserInfo (OpenID Connect) | https://rederp.ai/oauth/userinfo | sub, email, email_verified: true, name of the linked user |
| JWKS | https://rederp.ai/oauth/jwks.json | RSA 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 asclient_id; RedERP fetches and validates the JSON document (ChatGPT uses this). Advertised withclient_id_metadata_document_supported: true. - Dynamic client registration —
POST https://rederp.ai/oauth/registerwithredirect_uris,client_name,token_endpoint_auth_method, … returns aclient_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
| Scope | Grants |
|---|---|
sales:read | All read tools (clients, products, stock, documents, payments, statements, KPIs, PDF links) |
sales:write | Create clients / documents / lines, forward status changes, conversions, payments |
openid, email, profile | OpenID 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
| Token | Lifetime | Notes |
|---|---|---|
| Authorization code | 5 minutes, single use | Bound to the PKCE challenge, redirect URI and resource |
| Access token | 1 hour | Opaque bearer token (rerp_at_…), audience https://rederp.ai/mcp; only its hash is stored |
| Refresh token | 30 days | Opaque (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.