An authorization code is a short lived intermediate credential used to complete the login and consent exchange. An access token is the credential the agent later presents to the MCP server to prove permission. In practice, the code is exchanged once at the token endpoint, while the access token is used repeatedly until it expires or is revoked.
Why This Matters for Security Teams
In an MCP flow, the distinction between an authorization code and an access token is not academic. The code is a one-time bridge in the OAuth exchange; the access token is the artifact that can actually reach the server. That matters because most real incidents involve the token, not the code, and token misuse turns a single login event into repeated API access. Guidance from the OWASP Non-Human Identity Top 10 is clear that long-lived or exposed machine credentials create durable risk.
For agentic systems, the stakes are higher because an autonomous agent may exchange a code, receive a token, and immediately start chaining tool calls without a human in the loop. That is why token scope, expiry, revocation, and audience checks matter more than the abstract OAuth flow itself. The security question is not whether the login happened correctly, but whether the resulting token can be replayed, forwarded, or overused in ways the operator did not intend. In practice, teams often discover token exposure only after an agent has already used it across multiple systems, not during the original consent event.
How It Works in Practice
In a standard OAuth exchange, the authorization code is returned after the user or workload completes authentication and consent. It is short lived, single use, and meant to be redeemed at the token endpoint. The access token is then issued to the client and presented to the MCP server on each request that needs authorization. That separation reduces the value of the code if it is intercepted, but it does not make the flow safe by itself. The access token is the credential that must be protected, audited, and constrained.
For MCP, the practical question is where the token lives and how long it remains valid. Stronger implementations treat the token as an ephemeral workload credential, not a reusable session secret. Current guidance suggests combining short token TTLs, narrow scopes, audience restriction, and server-side revocation controls. Where possible, operators should bind tokens to the workload identity that requested them, so a stolen token is harder to replay elsewhere. This is especially relevant in autonomous workflows, where an agent may request a token for one task and then continue operating after the original intent has changed.
- Use the authorization code only for the token exchange step, never as a reusable credential.
- Use access tokens only for the target MCP server and restrict their scope to the minimum needed.
- Prefer short-lived tokens for agents, because long-lived tokens expand the blast radius of tool chaining.
- Track issuance, use, and revocation separately so investigators can distinguish login from runtime access.
NHI Management Group has documented how exposed tokens drive real-world compromise, including the Salesloft OAuth token breach and the JetBrains GitHub plugin token exposure, both of which show how quickly a token becomes a lateral-movement tool once it is outside the intended trust boundary.
These controls tend to break down in distributed agent fleets with shared secret stores and weak token audience enforcement because one issued token can be reused across multiple tools and environments.
Common Variations and Edge Cases
Tighter token lifetimes often increase operational overhead, so organisations must balance usability against replay risk. That tradeoff becomes sharper when MCP clients are autonomous, because an agent may need to complete a workflow without waiting for human reauthentication. Current guidance suggests that there is no universal standard for token TTL in agentic MCP deployments yet, so the right answer depends on task sensitivity, revocation speed, and how much the token can do if stolen.
One common edge case is confusing the code flow with proof of authorization. The code is not what the MCP server should trust; it is only a transient artifact for the token endpoint. Another is using the same access token across unrelated tools, which undermines least privilege and makes incident response harder. A third is assuming refresh tokens are harmless because they are not sent on every request. For autonomous workloads, refresh tokens can be the most sensitive object in the chain because they extend the session beyond the original interaction.
Where agentic systems are involved, the safer pattern is to treat tokens as task-scoped and revocable, with policy checked at runtime rather than assumed from the original login. That approach aligns with emerging guidance in the OWASP Agentic AI Top 10. It also fits broader risk thinking in the NIST SP 800-53 Rev 5 Security and Privacy Controls, which emphasizes access control, monitoring, and credential lifecycle management. When MCP deployments span multiple tenants or rely on long-lived refresh tokens, the simple code-versus-token distinction stops being enough because the real exposure shifts to token propagation and reuse.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Agentic AI Top 10, OWASP Non-Human Identity Top 10 and CSA MAESTRO address the attack and risk surface, while NIST AI RMF and NIST Zero Trust (SP 800-207) set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Agentic AI Top 10 | A1 | Agentic systems can misuse tokens after issuance if scope and intent drift. |
| OWASP Non-Human Identity Top 10 | NHI-03 | OAuth tokens are non-human credentials that must be rotated and limited. |
| CSA MAESTRO | IAM | MAESTRO addresses identity and access for autonomous agent workflows. |
| NIST AI RMF | AI RMF governance applies to autonomous access decisions and token misuse risk. | |
| NIST Zero Trust (SP 800-207) | SC-23 | Zero trust favors continuous verification and limited credential replay. |
Verify each MCP request at runtime and constrain token use to the intended service.
Related resources from NHI Mgmt Group
- What is the difference between stored credentials and OAuth-based MCP access?
- What is the difference between access tokens and refresh tokens in OAuth risk management?
- What is the difference between OAuth Token Exchange and AuthZEN in delegated MCP access?
- What is the difference between an authorization code and an access token in OAuth?