The authorization code is a short-lived, single-use value returned after consent and used only to obtain tokens. The refresh token is a longer-lived credential that can be used later to request a new access token when the original one expires. In practice, the code starts the session, while the refresh token supports ongoing access without repeated user login.
How the OAuth 2.0 authorization code differs from the refresh token
The distinction is mainly about purpose and timing. The authorization code is a short-lived, one-time credential used immediately after the user consents, while the refresh token is a longer-lived credential used later to obtain new access tokens without sending the user back through the full login flow. The code is a handoff step, the refresh token is a renewal mechanism.
That difference matters because the authorization code is meant to be transient and tightly bound to the front-channel redirect flow, whereas the refresh token exists to preserve continuity after the initial exchange. A well-designed OAuth implementation treats them as different trust objects with different exposure and revocation implications, which is why token handling guidance separates them carefully in OAuth 2.0 and OpenID Connect Guide for Identity Teams and RFC 6749: The OAuth 2.0 Authorization Framework.
The authorization code is normally exchanged only once and very quickly loses value after use. The refresh token, by contrast, is designed for repeated use over a longer period, so it becomes the more sensitive credential in operational terms. If either one is intercepted, the attacker’s options are different: a stolen code usually has a narrow replay window, while a stolen refresh token can support ongoing access until it is revoked, rotated, or expired. That is why refresh-token hygiene is a first-class concern in Token and Session Security Guide and RFC 9700: Best Current Practice for OAuth 2.0 Security.
One practical way to think about the pair is that the authorization code proves the browser-based consent step completed, while the refresh token preserves the relationship after that step. Many security failures come from confusing those roles, especially when teams overexpose refresh tokens in logs, browsers, mobile storage, or app integrations. Where an OAuth flow is used between SaaS platforms, the longer-lived token deserves the stricter controls and review process, as shown in SaaS-to-SaaS and OAuth App Governance Guide.
The authorisation code is also safer precisely because it is not meant to be a durable credential. It is a temporary artifact of the redirect flow, so the security objective is to keep it short-lived, single-use, and protected against interception or substitution. The refresh token, by contrast, should be treated as a stored secret with explicit lifecycle controls, because compromise shifts the issue from one login event to persistent access. If you want a deeper reference on token lifetimes, rotation, and replay resistance, the most relevant practical material is OAuth Refresh Token Rotation and Expiry Guide.
Risk and Threat Considerations
The main security difference is exposure window. A stolen authorization code usually has limited value if the exchange happens promptly, but a stolen refresh token can extend access far beyond the original login event and may survive user awareness. That makes refresh tokens a common target in token theft, consent phishing, and compromised integration scenarios.
Failure mechanism: An attacker captures or reuses the longer-lived token, then silently mints new access tokens without needing the user to authenticate again. If the implementation does not rotate refresh tokens, detect reuse, or revoke them quickly, the attacker can keep access even after the initial access token expires.
Impact: The result is persistent unauthorized access, often with a much longer dwell time than a single stolen access token or authorization code would allow. In connected-app environments, that can turn one compromised consent or one leaked secret into repeated access to mail, CRM, or API data until the refresh token family is cut off.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
NIST SP 800-63, NIST SP 800-53 Rev 5, OWASP ASVS and CIS Controls v8 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| NIST SP 800-63 | Digital Identity Guidelines | OAuth authorization codes and refresh tokens are central digital-identity protocol artifacts. |
| Recommendation — Use NIST 800-63 guidance to keep authentication artifacts short-lived and bound to the right session. | ||
| NIST SP 800-53 Rev 5 | IA-5 — Authenticator Management | Refresh tokens function as long-lived authenticators that need lifecycle protection and revocation. |
| IA-2 — Identification and Authentication (Organizational Users) | OAuth exchanges depend on correctly authenticating the user before issuing tokens. | |
| Recommendation — Apply IA-5 to control issuance, storage, rotation, and revocation of refresh tokens. Use IA-2 to ensure the user is authenticated before token issuance. | ||
| OWASP ASVS | V10 — OAuth and OIDC | The question directly concerns OAuth 2.0 token roles and flow security. |
| Recommendation — Apply V10 to verify authorization-code and refresh-token handling in OAuth flows. | ||
| CIS Controls v8 | CIS-5 — Account Management | Token lifecycle and revocation affect account access continuity and persistence. |
| Recommendation — Enforce token lifecycle controls under CIS-5 to limit persistent access. | ||
Practitioner Guidance
What to verify: Check whether your application treats the authorization code as a one-time exchange artifact and the refresh token as a separately protected secret. If your logs, browser storage, or app telemetry ever expose refresh tokens, treat that as a higher-risk condition than code leakage.
Common mistake: Teams sometimes focus on access-token expiry and ignore refresh-token lifetime. That is a mistake because the refresh token is what keeps the session alive after the short-lived access token is gone. For operational follow-up, use OAuth Token Introspection and Revocation Guide to align revocation and validation behaviour.
Practitioner takeaway: Treat the authorization code as a transient exchange artifact and the refresh token as the durable asset, then design your controls around the token that can actually preserve access over time.
Related resources from NHI Mgmt Group
Deepen Your Knowledge
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.
Reviewed and updated by the NHIMG editorial team on November 5, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org