Join our Newsletter — 33% off our NHI Course
Authentication, Authorisation & Trust

Authorisation Code

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

An Authorisation Code is a short-lived, one-time credential issued by an OAuth 2.0 authorisation server after user consent, which the client exchanges at the token endpoint for tokens. Attackers try to intercept it through redirect manipulation. Defenders require PKCE, register exact redirect URIs, and reject reused codes.

What the authorisation code does in the OAuth 2.0 flow

The authorisation code is the short-lived handoff that sits between user consent and token issuance. It is designed to be usable only once, by the intended client, and only for a very brief window. That makes it a safer intermediary than exposing tokens directly in the browser redirect.

In practice, the code is not the user’s access token, and it is not meant to be treated as a bearer credential outside the OAuth exchange. Its purpose is to let the client prove it completed the front-channel step and then finish the flow at the token endpoint under tighter control.

Why it is attractive to attackers

The main security problem is interception during the redirect sequence. If an attacker can manipulate the redirect path, capture the code, or trick the browser into sending it somewhere else, they can attempt to redeem it before the legitimate client does. That is why the authorisation code flow is built around strict redirect handling and proof that the same client is finishing the exchange.

This is also why the code itself is intentionally short-lived and one-time. Reuse should fail, and any successful replay means the implementation has lost control of one of the flow’s core trust assumptions.

How the flow stays safe

The strongest protection is PKCE, which binds the front-channel code to a verifier known only to the client that started the request. Exact redirect URI registration closes off broad or wildcard callback abuse, and code reuse checks prevent replay after interception. The result is a flow that is still practical for browser-based sign-in, but much harder to hijack.

For teams implementing or reviewing OAuth, the security question is not just whether the flow works, but whether the client, redirect URI, and token exchange are all bound tightly enough to stop code theft from becoming token theft. The OAuth 2.0 and OpenID Connect Guide for Identity Teams and the FAPI 2.0 Security Profile Implementation Guide both cover the surrounding controls that make the exchange resilient.

Where authorisation code mistakes show up in real designs

Misuse usually appears when teams treat the code like a harmless transport artifact rather than a protected credential. Weak redirect validation, missing PKCE, sloppy callback matching, or accepting reused codes can all let an attacker convert a browser-side interception into a valid token grant. In higher-assurance deployments, these failures often sit alongside broader authorisation design mistakes, which is why the Authorisation Models Guide is a useful companion for understanding how access decisions and token-bearing identities should be constrained.

When authorisation code handling is reviewed properly, the focus is on the exact browser-to-token boundary, not just on whether authentication succeeds. That is where interception, replay, and redirect confusion become operationally visible.

Risk and Threat Considerations

Authorisation code weaknesses are dangerous because they turn a short-lived front-channel artifact into a route to account compromise. If an attacker can obtain the code and race the legitimate client, they may gain the tokens that follow, which can expose the user’s session and any downstream privileges attached to it.

Failure mechanism: Redirect manipulation, code interception, missing PKCE, or reused-code acceptance lets an attacker redeem the code before the intended client completes the token exchange.

Impact: The result can be token theft, session takeover, and unauthorized access that looks like a normal OAuth success path unless the exchange and replay controls are enforced.

Standards & Framework Alignment

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

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

FrameworkControl / ReferenceRelevance
OWASP ASVSV10 — OAuth and OpenID ConnectAuthorisation code flow is an OAuth/OIDC core pattern.
Recommendation — Verify PKCE, redirect URI handling and token exchange rules in OAuth and OIDC implementations.
NIST SP 800-63Digital Identity GuidelinesDefines phishing-resistant and federation controls around browser-based identity flows.
Recommendation — Use the digital identity guidance to harden federated sign-in and callback handling.
NIST SP 800-53 Rev 5IA-5 — Authenticator ManagementThe code is one-time authentication material that must be protected from reuse and interception.
IA-9 — Identification and Authentication (Non-Organizational Users)OAuth authorisation codes commonly support external-user sign-in and token issuance.
Recommendation — Manage short-lived code material so it cannot be replayed or reused after issuance. Bind external-user flows to the intended client and reject unauthorized token redemption.
CIS Controls v8CIS-6 — Access Control ManagementThe flow depends on controlled redirect and token access paths.
Recommendation — Restrict callback and token-exchange access paths to reduce interception risk.

Practitioner Guidance

Why practitioners should care: The authorisation code is one of the most security-sensitive objects in OAuth because it bridges a user-facing browser redirect and a privileged token grant. Reviewers should treat any code handling logic as security-critical, not just plumbing.

Common misunderstanding: Teams sometimes assume that HTTPS alone protects the flow. In reality, HTTPS does not stop redirect abuse, callback confusion, or a stolen code being redeemed by the wrong party if client binding is weak.

Practitioner takeaway: Validate the full redirect and exchange path as a control boundary, not just the login experience, and require the code to be bound, short-lived, and non-replayable.

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 November 26, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org