How Claude’s Token Works
Claude authenticates the user and sends a standard OAuth access token where thesub claim is the authenticated user. The token does not include delegation semantics — there is no act claim or separate agent identity. From the token alone, the Gateway cannot distinguish “Claude acting on behalf of the user” from “the user directly.”
This has implications for how the Gateway evaluates and processes requests:
- Inbound authorization policies operate on the token as received. Since Claude does not perform a token exchange before calling the Gateway, inbound OPA policies see only the claims in the access token — by default, user identity claims (
sub,email,groups, etc.). The token does not carry agent identity unless the Auth Provider Orchestrator is configured to include it via abuildAccessTokenClaimsSEservice extension — for example, by adding theclient_idas a custom claim or constructing anactclaim to simulate delegation semantics. These values are not cryptographically verified — they are set by the Auth Provider based on the OAuth request context. Care should be taken in the service extension to derive them from a trusted source rather than upstream identity provider attributes that could be manipulated. - Outbound token exchange is where the Gateway adds delegation semantics. When the Gateway performs RFC 8693 token exchange to call upstream APIs via MCP Bridge or MCP Proxy, it can mint delegation tokens with an
actclaim that includes the agent’s client identity. This gives upstream services visibility into both the user and the agent that initiated the request.
Today, Claude’s
client_id is a self-asserted string (e.g., "claude") with
no cryptographic proof of the agent’s identity. Because Claude is a closed
platform, customers are limited to what Claude supports out of the box —
unlike custom agents or other AI clients, which can implement proof of
possession, delegation chains, workload attestation, and other advanced
identity patterns directly.Several emerging standards aim to address agent identity and delegation:- OAuth Client ID Metadata Documents (CIMD)
strengthen client identity by using an HTTPS URL as the
client_id. The authorization server fetches and validates the metadata document, providing verified (rather than self-asserted) client identity for policy decisions. - WIMSE (Workload Identity in Multi-System Environments) and SPIFFE (Secure Production Identity Framework For Everyone) provide cryptographically attested workload identity, enabling agents to prove who they are independently of OAuth client registration.
- The AI Agent Authentication and Authorization
IETF draft ties these together, proposing that agents are workloads with
WIMSE/SPIFFE identifiers and that access tokens carry dual identity:
client_idas the agent’s verifiable workload identity andsubas the delegated user.
sub, email, groups,
etc.). The client_id is available to token minting
policies on the Auth Provider Orchestrator but is not included in the access
token by default — customers can use
service extensions such as
buildAccessTokenClaimsSE to add client_id, an act claim, or other
context to the token so the Gateway’s inbound policies can evaluate it.
This can simulate delegation semantics by constructing an act claim with
the client identity as the actor. The service extension should derive these
values from a trusted source within the Auth Provider’s request context, not
from upstream identity provider attributes that could be manipulated.Prerequisites
- A running AI Identity Gateway — Follow the AI Identity overview to set up the Auth Provider Orchestrator and AI Identity Gateway Orchestrator with at least one MCP Bridge or MCP Proxy app configured. The Gateway must use the Streamable HTTP transport — SSE is not supported by Claude’s connector infrastructure.
- OAuth authorization enabled on the MCP Provider — The Gateway’s
mcpProvider.authorization.oauthmust be enabled so Claude can authenticate. See the AI Identity Gateway reference for configuration details. - Claude Desktop, Claude Code, or a claude.ai account — Any Claude client that supports remote MCP servers works with this guide.
Claude requires an interactive OAuth flow where a user authenticates via the
browser. The
client_credentials grant type (machine-to-machine OAuth with no
user interaction) is not supported by Claude’s MCP connector infrastructure.
Register Claude with the authorization_code and refresh_token grant types.
See the Anthropic Connectors Directory FAQ
for details on Claude’s connector requirements.Choose a Client Type
When you register Claude as an OAuth client with the Auth Provider Orchestrator, you choose between a confidential client or a public client. This choice affects how Claude authenticates to the authorization server.| Confidential Client | Public Client | |
|---|---|---|
| Authentication | Client ID + client secret | Client ID + PKCE (no secret) |
| Security | Stronger — the secret proves the client’s identity | Weaker — relies on PKCE alone to protect the authorization code flow |
| Best for | Claude Code (CLI), server-side integrations | Environments where a client secret cannot be securely stored |
| Grant types | Authorization Code, Refresh Token | Authorization Code (with PKCE), Refresh Token |
Register Claude as an OAuth Client
Register Claude as an OIDC application on the Auth Provider Orchestrator — the same orchestrator deployment that issues tokens for the AI Identity Gateway. This gives Claude the credentials it needs to authenticate and obtain access tokens.- Confidential Client (Recommended)
- Public Client
- Console UI
- Configuration
Navigate to Applications
Go to Applications in the sidebar and click Create. Select OIDC-based from the application type list.
Configure client credentials
Enter a Client ID (e.g.,
claude). Leave Client Authentication Method set to Client Secret. Click Add Client Secret and enter a strong secret or a secret provider reference (e.g., <vault.claude_secret>).Add redirect URLs
Click Add Redirect URL and add the redirect URLs for the Claude clients you plan to use:
- claude.ai and Claude Desktop:
https://claude.ai/api/mcp/auth_callbackandhttps://claude.com/api/mcp/auth_callback - Claude Code:
http://localhost:{PORT}/callbackwhere{PORT}is a fixed port you choose (e.g.,http://localhost:29352/callback). Users must pass--callback-port {PORT}when adding the MCP server in Claude Code. See the Connect Claude Code section for details. - Claude Desktop via mcp-remote:
http://localhost:{PORT}/oauth/callback(e.g.,http://localhost:3334/oauth/callback). Note the/oauth/callbackpath — this differs from Claude Code’s/callbackpath.
Configure grant types
Under Grant Types, ensure the following are checked:
- Authorization Code (under Recommended and Modern Flows)
- Refresh Token (under Recommended and Modern Flows)
Configure access token settings
Leave Type set to JWT. Optionally set Lifetime Seconds (default is 1 hour).
Enable refresh tokens
Under Refresh Token Settings, toggle Allow Offline Access on. This lets Claude refresh expired access tokens without requiring you to re-authenticate.
Create a User Flow
After creating the OIDC application, you need to connect it to an identity connector and associate it with the Auth Provider deployment. In the Console UI, this is done by creating a User Flow. In YAML, theauthentication.idps field on the app handles this directly.
- Console UI
- Configuration
Create a User Flow
Navigate to User Flows in the sidebar and click Create. Enter a name (e.g.,
Claude Auth) and select your Claude application from the Select an application dropdown, then click Create.Configure the authentication source
On the User Flow page, find the Sign On Policy card and click Edit. Under Authentication, select your identity connector from the Select an authentication source dropdown. This is the identity connector configured on the Auth Provider Orchestrator (e.g., your Entra ID, Okta, or Keycloak connector). Click Save.
Publish the configuration
Navigate to the deployment’s Settings page and click Publish Preview in the footer bar. Review the configuration diff, optionally add a revision note, and click Publish. The Orchestrator picks up the new configuration on its next poll cycle.See Publishing Deployment Configs for details on the publishing lifecycle.
Connect Claude to the Gateway
Once Claude is registered as an OAuth client and associated with your identity connector, configure your Claude client to connect to the AI Identity Gateway’s MCP endpoint. Claude will automatically discover the authorization server via the Gateway’s protected resource metadata and prompt you to authenticate. How you connect depends on whether the AI Identity Gateway is publicly accessible or on a private network:- Publicly accessible Gateway — All client tabs below work. Use a confidential client (client ID + secret) so the secret proves the client’s identity to the authorization server. The Organization (Team / Enterprise) tab configures a web connector that routes through Anthropic’s infrastructure — both the Gateway and Auth Provider Orchestrator must be reachable from the public internet.
- Private / internal Gateway — Select the Claude Code or Claude Desktop tab below. These clients connect directly from your machine, so local and private network URLs work. Use a public client (client ID + PKCE, no secret) to avoid distributing and managing secrets across individual machines.
- Claude Code
- Claude Desktop
- Organization (Team / Enterprise)
Add the AI Identity Gateway as a remote MCP server using the Claude Code CLI. Claude Code connects directly from your machine, so the Gateway does not need to be publicly accessible. The Auth Provider Orchestrator requires pre-registered OAuth clients rather than Dynamic Client Registration (DCR), giving administrators full control over which applications can request tokens. You must pass the OAuth client credentials explicitly when adding the server. You also need When you start a Claude Code session, Claude connects to the Gateway, discovers the authorization server, and opens your browser for OAuth authentication.Managing the connection:Inside a Claude Code session, use the
--callback-port to fix the OAuth redirect URI to match the pre-registered redirect URL.- Public Client
- Confidential Client
If you registered Claude as a public client on the Auth Provider Orchestrator, pass only
--client-id. Claude Code uses PKCE (Proof Key for Code Exchange) to protect the authorization code flow — no client secret is needed.--client-id claude-publicprovides the OAuth client ID so Claude Code can authenticate without DCR.--callback-port 29352fixes the OAuth redirect URI tohttp://localhost:29352/callback, matching the redirect URL registered in the OIDC app. Without this flag, Claude Code picks a random port that would not match.
/mcp slash command to check server status, authenticate, and manage connections:- Authenticate — Run
/mcpand select the AI Identity Gateway to open the browser OAuth flow. Claude Code stores tokens securely and refreshes them automatically. - View available tools — After authenticating, Claude automatically discovers tools from the Gateway. Ask Claude to list available tools or use
/mcpto check the server’s connection status and tool count. - Clear authentication — Run
/mcp, select the AI Identity Gateway, and choose Clear authentication to revoke the stored OAuth tokens. Use this when switching users, troubleshooting token issues, or revoking access. - Reauthenticate — After clearing authentication, run
/mcpagain and select the Gateway to start a fresh OAuth flow.
Harden Token Issuance with Token Minting Policies
The Auth Provider Orchestrator supports OPA token minting policies that evaluate every token request before issuance. These policies add a governance layer on top of OAuth client registration — even after a user authenticates successfully, the Orchestrator can deny or constrain the token based on client identity, grant type, requested scopes, or environmental conditions. This is especially valuable when using public clients. Because public clients authenticate with only a client ID and PKCE (no secret), any application that knows the client ID can initiate an authorization flow. Token minting policies let you enforce additional constraints at the point of token issuance to compensate — for example, restricting which networks can mint tokens for a given client.Public client is an OAuth term describing how the client authenticates (no
secret, PKCE only) — it does not mean the Gateway is publicly accessible. A
public client can connect to a Gateway on a private network (e.g., Claude Code
or Claude Desktop via mcp-remote connecting to an internal Gateway). Similarly,
a publicly accessible Gateway can use confidential clients. The client type and
deployment model are independent choices.
Example: Restrict a Private Gateway to Corporate Networks
The following policy ensures that the public clientclaude-public can only mint tokens when the request originates from the corporate network. This is useful when the Gateway is on a private network and you want to ensure tokens are only issued to users connecting from known internal ranges:
maverics.yaml
claude-public unless the request originates from the 10.0.0.0/8 CIDR range. Replace the CIDR with your organization’s internal network range. You can combine multiple net.cidr_contains checks to allow several network ranges.
Source IP checks are a useful defense-in-depth measure but should not be your
only security control. Client IPs can be obscured by proxies, VPNs, or NAT,
and the
input.source.ip value reflects the immediate connection to the
Orchestrator, which may be a load balancer or reverse proxy rather than the
end user’s machine. Use IP restrictions alongside other controls — such as
user authentication, PKCE, and scoped token lifetimes — rather than relying
on them in isolation.Example: Restrict a Public Gateway to Anthropic’s IP Ranges
When the Gateway is publicly accessible and Claude connects via claude.ai or Claude Desktop web connectors, traffic arrives from Anthropic’s published outbound IP ranges. The following policy restricts token issuance to requests originating from these ranges:maverics.yaml
maverics.yaml
input.request.oauth.client_id, input.request.oauth.scope, input.request.oauth.audience, input.request.oauth.grant_type, and input.source.ip. See the token minting policy reference for the full list of available input fields.
IP Allowlisting for Public Deployments
When the AI Identity Gateway and Auth Provider Orchestrator are publicly accessible, you can restrict inbound traffic to known IP ranges as an additional layer of protection. Understanding the traffic flow is important for applying restrictions at the right layer:- User’s browser → Auth Provider — During the OAuth authorization step, the user’s browser connects directly to the Auth Provider Orchestrator’s authorize endpoint. This traffic comes from the user’s IP, not Anthropic’s.
- Anthropic’s backend → Auth Provider — Token exchange and token refresh requests are made server-side by Anthropic’s infrastructure. This traffic comes from Anthropic’s published outbound IP ranges.
- Anthropic’s backend → Gateway — MCP tool calls are routed through Anthropic’s infrastructure. This traffic also comes from Anthropic’s outbound IP ranges.
- Gateway infrastructure-level allowlisting — The Gateway can be locked down to Anthropic’s outbound IP ranges (
160.79.104.0/21for IPv4,2607:6bc0::/48for IPv6) since only Anthropic’s backend connects to it for web connectors. Use your cloud provider’s firewall, security groups, WAF, or reverse proxy. - Auth Provider infrastructure-level allowlisting — The Auth Provider cannot be restricted to Anthropic’s IPs alone because the user’s browser must reach the authorize endpoint during the OAuth flow. However, it does not need to be open to the entire internet — organizations can restrict access to Anthropic’s outbound IP ranges plus their own users’ networks using VPNs, corporate IP allowlists, device management policies, or conditional access controls. The key requirement is that both Anthropic’s infrastructure and the user’s device can reach the Auth Provider.
- Auth Provider token minting policies — OPA token minting policies evaluate at the token endpoint, where requests come from Anthropic’s backend (for web connectors) or the user’s machine (for Claude Code / mcp-remote). Use the examples above to restrict by source IP at this layer.
- Gateway inbound authorization policies — Use OPA policies on the AI Identity Gateway to restrict tool invocations by source IP. This controls who can call tools even with a valid token.
Verify the Connection
After connecting, verify that Claude can discover and invoke tools from the AI Identity Gateway.- Check tool discovery — Ask Claude to list available tools. Claude should display the MCP tools exposed by your MCP Bridge and MCP Proxy apps. Tool names include the namespace prefix (e.g.,
my_api_listUsers). - Invoke a tool — Ask Claude to call one of the discovered tools. For example: “List all users using the my_api_listUsers tool.” The AI Identity Gateway authenticates the request, evaluates authorization policies, performs token exchange, and returns the result.
- Check the Orchestrator logs — The AI Identity Gateway Orchestrator logs show the complete request flow: agent authentication, OPA policy evaluation, token exchange, and upstream API call. Verify that all steps completed successfully.
If Claude cannot discover tools or tool invocations fail, see the troubleshooting
sections in the Expose APIs to Agents
and Protect MCP Servers guides.
Troubleshooting
OAuth redirect URI mismatch
OAuth redirect URI mismatch
The redirect URI Claude sends does not match what is configured in the OIDC
app’s
redirectURLs.Resolution:- Check the Auth Provider Orchestrator logs for the exact
redirect_urivalue Claude is sending. - Add that exact URI (including scheme, host, port, and path) to the OIDC
app’s
redirectURLsarray. - For claude.ai and Claude Desktop, ensure both
https://claude.ai/api/mcp/auth_callbackandhttps://claude.com/api/mcp/auth_callbackare in the redirect URLs list. - For Claude Code, ensure you passed
--callback-portwhen adding the MCP server, and thathttp://localhost:{PORT}/callbackwith that port is in the redirect URLs list. Without--callback-port, Claude Code picks a random port that will not match any pre-registered URL. - For Claude Desktop via mcp-remote, ensure
http://localhost:{PORT}/oauth/callbackis in the redirect URLs list. Note the/oauth/callbackpath — this differs from Claude Code’s/callbackpath. The default port is3334.
Claude cannot discover any tools
Claude cannot discover any tools
If Claude connects and authenticates but sees no tools:
- Verify that MCP Bridge or MCP Proxy apps are configured and running on the AI Identity Gateway Orchestrator.
- Check that the agent’s token has the required scopes for tool discovery.
- Review the AI Identity Gateway Orchestrator logs for errors during tool registration or upstream connection failures.
- Confirm that inbound OPA policies do not block tool listing.
Authentication popup does not appear
Authentication popup does not appear
If Claude does not prompt you to authenticate when connecting to the Gateway:
- Verify that
mcpProvider.authorization.oauth.enabledistrueon the AI Identity Gateway Orchestrator. - Check that the Gateway’s
/.well-known/oauth-protected-resourceendpoint is reachable and returns valid metadata. - Ensure the Auth Provider Orchestrator’s well-known endpoint is listed in the
Gateway’s
mcpProvider.authorization.oauth.serversconfiguration. - For Claude Desktop, confirm you restarted the application after editing the configuration file.
Token refresh fails after session expires
Token refresh fails after session expires
If Claude’s session stops working after the access token expires:
- Verify that the OIDC app’s
grantTypesincludesrefresh_token. - Check that
refreshToken.allowOfflineAccessistruein the OIDC app configuration. - Confirm the refresh token has not expired (check
refreshToken.lifetimeSeconds). - If using a confidential client, ensure the client secret has not been rotated or revoked since the session was established.
Tokens remain valid after disconnecting in claude.ai
Tokens remain valid after disconnecting in claude.ai
When a user disconnects a connector in claude.ai or Claude Desktop, Anthropic
removes the tokens from its systems but does not revoke them at the identity
provider. Access and refresh tokens on the Auth Provider Orchestrator remain
valid until they expire, and session cookies are not cleared.Resolution:
- Set short
accessToken.lifetimeSecondsvalues (e.g., 300—900 seconds) to limit the window of validity after disconnection. - Set
refreshToken.lifetimeSecondsto bound how long a refresh token can extend a session. - If immediate revocation is required, revoke the user’s session directly on the Auth Provider Orchestrator or upstream identity provider.
TLS certificate verification fails with mcp-remote
TLS certificate verification fails with mcp-remote
If Resolution (development only): For local development with self-signed
certificates, you can disable TLS verification entirely. Do not use
this in production.
mcp-remote fails with UNABLE_TO_VERIFY_LEAF_CERTIFICATE or similar
TLS errors, the Gateway’s certificate is not trusted by Node.js. This is
common with self-signed certificates, internal CAs, or VPN-intercepted
connections.Resolution (recommended): Point NODE_EXTRA_CA_CERTS to your
organization’s CA certificate file so Node.js trusts the Gateway’s
certificate chain:claude_desktop_config.json
claude_desktop_config.json
Related Pages
AI Identity Overview
Set up the Auth Provider Orchestrator and understand agent identity concepts
Expose APIs to Agents
Make REST APIs available to Claude as MCP tools via MCP Bridge
Protect MCP Servers
Add identity governance to existing MCP servers via MCP Proxy
OIDC App Reference
Full configuration reference for OAuth client registration
Anthropic Documentation
Connectors Directory FAQ
Critical reference covering connector architecture, traffic routing, OAuth requirements, token limits, timeouts, and privacy details
Claude Code MCP Configuration
Claude Code docs covering MCP transports, OAuth options, and callback port configuration
Remote MCP on claude.ai
How to add remote MCP servers as connectors on claude.ai, including plan requirements
Building Custom MCP Connectors
Developer guide for building OAuth-protected MCP servers that work with Claude
Building Desktop Extensions
How to package local MCP servers as desktop extensions (.mcpb) for enterprise distribution
MCP Quick Start for Claude Desktop
MCP protocol docs for configuring MCP servers in Claude Desktop