Join our Newsletter — 33% off our NHI Course
Home› Glossary› Authentication, Authorisation & Trust› OAuth 2.0 Authorization Code Flow
Authentication, Authorisation & Trust

OAuth 2.0 Authorization Code Flow

← Back to Glossary
By NHI Mgmt Group Updated October 28, 2026 Domain: Authentication, Authorisation & Trust

OAuth 2.0 Authorization Code Flow is an OAuth 2.0 grant used by an application to obtain an access token on behalf of a user after the user authenticates and approves consent. The authorisation code is exchanged server-side for tokens, which keeps the user’s credentials out of the client and reduces token exposure in browser-based flows.

How the Authorization Code Flow Works

The authorization code flow is a two-step pattern: the user authenticates and consents with the authorization server, then the application exchanges a short-lived code server-side for tokens. That separation is what makes it the preferred OAuth flow for web apps that can keep a client secret or otherwise protect back-channel requests.

For a useful standards anchor, RFC 6749: The OAuth 2.0 Authorization Framework is the core specification that defines this grant and its message flow.

The security property worth preserving is that the browser never needs to handle the application’s long-term credentials or the token exchange itself. That reduces exposure compared with older front-channel patterns, because the code is only an intermediate artifact and the tokens are obtained over a server-to-server step.

Where This Flow Fits in OAuth and OpenID Connect

This flow is the bridge between user authorization and application access. It is commonly used when an application needs delegated access to a protected resource after a user has explicitly approved the request, and it pairs naturally with OpenID Connect when the application also needs a login identity layer.

For teams maintaining OAuth and OIDC implementations, the OAuth 2.0 and OpenID Connect Guide for Identity Teams provides the broader model of roles, grant types, scopes, tokens and client types that helps place this flow in context.

The key distinction is that OAuth grants access to resources, while OpenID Connect adds authentication semantics through ID tokens. In practice, many implementation mistakes come from mixing those responsibilities or assuming that an access token alone proves who the user is.

Why It Is Safer Than Front-Channel Token Handling

Authorization code flow exists to reduce token exposure. Because the code is exchanged on the server side, it avoids placing reusable access credentials directly into the browser history, URLs, or client-side scripts, where they are easier to steal or replay.

That protection becomes especially important when the application is connected to third-party APIs or high-value user data. The flow does not remove risk entirely, but it narrows the attack surface by limiting what the front channel sees and by making the token exchange dependent on the application’s authenticated back end.

For a more detailed security view of OAuth deployment hardening, RFC 9700: Best Current Practice for OAuth 2.0 Security is the most directly relevant companion standard.

Common Implementation Decisions and Failure Modes

The flow’s safety depends on implementation discipline. Redirect URI handling, code exchange integrity, scope design, client authentication, and token audience restrictions all affect whether the flow actually delivers the intended security benefit.

Teams should also treat PKCE, state validation, and exact redirect matching as part of the same security conversation, because these controls close the most common abuse paths around interception and request tampering. If the application cannot keep a secret, or if the deployment is a public client, the surrounding protections become even more important.

When you want a concrete model for safer browser and native app deployments, the OAuth 2.0 and OpenID Connect Guide for Identity Teams is the best NHIMG starting point, while RFC 6749: The OAuth 2.0 Authorization Framework remains the normative reference.

Risk and Threat Considerations

The main risk is not the grant itself, but weak deployment of it. If codes, redirects, or tokens are intercepted, an attacker can turn a legitimate delegated session into persistent unauthorized access, especially where scopes are broad or token lifetimes are long.

Failure mechanism: Attackers abuse redirect manipulation, code interception, consent phishing, or weak client validation to capture authorization artifacts and exchange them for usable tokens.

Impact: Stolen tokens can enable mailbox access, API abuse, session persistence, or lateral movement into connected services until the tokens are revoked or expire.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

NIST SP 800-53 Rev 5 and OWASP ASVS set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
NIST SP 800-53 Rev 5IA-5 — Authenticator ManagementAuthorization code flows depend on secure client secrets and token handling.
IA-8 — Identification and Authentication (Non-Organizational Users)User-authorized OAuth sessions rely on external-user authentication before delegated access is issued.
Recommendation — Protect and rotate OAuth client credentials and other authenticators that secure the code exchange. Require strong authentication for external users before issuing delegated OAuth access.
OWASP ASVSV10 — OAuth and OIDCASVS V10 directly governs secure OAuth and OpenID Connect implementation details.
V7 — Session ManagementThe flow ultimately creates bearer sessions that must be protected after issuance.
V8 — AuthorizationScope and consent decisions determine what the client may access on the user’s behalf.
Recommendation — Verify OAuth redirect handling, consent, token exchange and client authentication under V10. Treat issued OAuth tokens as session material and validate their lifetime, storage and replay resistance. Enforce least-privilege scope design and server-side authorization checks for delegated access.

Practitioner Guidance

Why practitioners should care: The authorization code flow is only as strong as the controls around it. Treat redirect URIs, code exchange, and token audience restrictions as security-critical parts of the design, not as incidental implementation details.

What to watch for: Unexpected consent prompts, mismatched redirect behavior, unusually broad scopes, and token use from unfamiliar client locations are all signs that the flow may be being abused or misconfigured.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on October 28, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org