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

OAuth 2.0 Authorization Code Flow With PKCE

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

OAuth 2.0 Authorization Code Flow with PKCE is an OAuth sign-in and delegated authorisation flow for browser-based or mobile apps. It swaps an authorisation code at the token endpoint after the client proves possession of a PKCE code verifier, which reduces code interception and protects public clients that cannot safely store a secret.

Why OAuth 2.0 Authorization Code Flow With PKCE Matters

This flow exists because browser-based and mobile apps cannot safely keep a client secret. PKCE adds a one-time proof step so the app can redeem the authorization code only if it still holds the original verifier, which makes intercepted codes far less useful.

That design is why the flow is widely preferred for public clients. It preserves delegated access without turning the app into a bearer-token dumping ground, and it narrows the most common interception and replay paths that affect modern front-end and mobile deployments.

For the standard’s core mechanics, see RFC 6749: The OAuth 2.0 Authorization Framework and RFC 9700: Best Current Practice for OAuth 2.0 Security.

How the Authorization Code Exchange Works

The user starts at the authorization server, authenticates there, and returns with an authorization code rather than a token. The client then sends that code to the token endpoint together with the PKCE verifier, which is checked against the earlier challenge before tokens are issued.

That exchange matters because the code is short-lived and single use, while the verifier never leaves the client during the authorization step. In practice, the verifier is what prevents a stolen code from being redeemed by a different party that only saw the redirect response.

For native and mobile implementation details, OAuth for Native and Mobile Apps Guide covers the redirect and browser choices that make this flow safer in public clients.

Where PKCE Adds Security

PKCE is a countermeasure for code interception, especially in apps that use custom redirects, embedded browsers, or operating-system handoffs where a malicious app or proxy might try to capture the authorization code. Without PKCE, a captured code can sometimes be enough to complete the token exchange.

It also helps close gaps created by weak client assumptions. A public client is not trusted to hold a secret, so security has to come from runtime proof of possession and from correct redirect handling rather than from static configuration alone.

That is why modern OAuth guidance increasingly treats PKCE as a baseline for public clients, not as an optional enhancement. The safer the client cannot store secrets, the more the flow must rely on proof-bound exchange rather than secret-based trust.

Common Implementation Pitfalls and Token Exposure

The most common failures are not in the abstract protocol but in the deployment around it: insecure redirects, overly permissive app registration, token leakage in logs or URLs, and accepting authorization responses from untrusted contexts. Those mistakes can undermine an otherwise sound flow.

Teams also misread PKCE as a replacement for all other OAuth hardening. It protects the code exchange, but it does not by itself fix weak consent UX, poor redirect validation, stale refresh-token handling, or downstream API authorization mistakes.

For a deeper view of OAuth misuse patterns and delegated-access boundaries, the AI Agent Authorisation Guide and Authorisation Models Guide are useful complements, because they explain how delegated access should be constrained once tokens are issued.

Risk and Threat Considerations

OAuth code interception is dangerous because a stolen authorization code can become a valid token grant if the exchange is not bound to the original client. The main threat is not merely theft of a transient code, but unauthorized access gained through replay, consent abuse, or token misuse after the redirect step.

Failure mechanism: An attacker intercepts the code during redirect, exploits a weak client or misconfigured redirect path, and redeems it before the legitimate app completes the token exchange.

Impact: The attacker may obtain access tokens or long-lived access to the protected resource, which can expose data, sessions, or downstream APIs even though the user only intended to authorise the real app.

Standards & Framework Alignment

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

OWASP API Security Top 10 addresses the attack and risk surface, while NIST SP 800-53 Rev 5, OWASP ASVS, CIS Controls v8 and NIST CSF 2.0 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
NIST SP 800-53 Rev 5IA-5 — Authenticator ManagementPKCE and OAuth token exchange depend on secure management of client authenticators and secrets.
Recommendation — Manage client credentials and related authenticators so public-client flows do not rely on unsafe shared secrets.
OWASP ASVSV10 — OAuth and OIDCThis term is an OAuth flow implementation topic with delegated authorization and token handling requirements.
Recommendation — Verify OAuth and OIDC flows to enforce secure redirects, code exchange, and token handling.
CIS Controls v8CIS-5 — Account ManagementOAuth-based sign-in and delegated access depend on controlling issued access paths and account lifecycle.
Recommendation — Control account and delegated access paths so issued OAuth privileges are reviewed and revoked appropriately.
NIST CSF 2.0PR.AA-05 — Authenticator ManagementThe flow relies on proving client possession during authentication and authorization exchange.
Recommendation — Use PKCE and related proof mechanisms to strengthen authentication exchange paths for public clients.
OWASP API Security Top 10API2 — Broken AuthenticationOAuth code flow failures often surface as broken authentication or token abuse at API boundaries.
Recommendation — Harden OAuth authentication flows so stolen codes or weak redirects cannot be redeemed for API access.

Practitioner Guidance

Why practitioners should care: Use PKCE by default for public clients and treat it as a required control, not a compatibility setting. The flow is only as strong as the redirect handling, verifier generation, and token endpoint validation around it.

What to watch for: Review whether the app uses a system browser, validates redirect URIs strictly, and avoids logging codes or tokens. If the client still depends on a stored secret, reconsider whether it is truly a public client or should be re-architected.

Practitioner takeaway: PKCE reduces the blast radius of code theft, but the rest of the OAuth deployment still has to be designed as if the redirect channel is observable.

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