
OAuth 2.0 and JSON Web Tokens (JWTs) are often compared as if they were competing ways to build login. They solve different problems. OAuth is an authorization framework for granting a client limited access to a protected resource. JWT is a format for representing claims. An OAuth access token can be a JWT, but it can also be an opaque string; many JWTs are not OAuth access tokens at all.
That distinction matters when you choose a design or review a token. If your application needs to know who signed in, use an identity protocol such as OpenID Connect (OIDC) on top of OAuth rather than treating an API access token as proof of login.
OAuth vs JWT at a glance
| Question | OAuth 2.0 | JWT |
|---|---|---|
| What is it? | A framework for delegated authorization and access to protected resources. | A compact, URL-safe format for carrying claims between parties. |
| What does it define? | Roles, authorization flows, and how a client obtains and uses an access token. | How claims are represented and, depending on the JWT type, signed or encrypted. |
| Is it a token format? | No. OAuth does not require access tokens to use a particular format. | Yes. A JWT is a token representation, not an authorization protocol. |
| Does it handle sign-in by itself? | OAuth alone is not an end-user authentication protocol. OIDC adds an identity layer. | A JWT may carry identity claims, but its format alone does not authenticate a user or authorize an API request. |
The OAuth 2.0 Authorization Framework (RFC 6749) defines OAuth's roles and flows. The JWT specification (RFC 7519) defines JWT as a way to represent claims. Neither specification says that every access token must be a JWT.
What OAuth does
OAuth lets a client obtain limited access to an API on behalf of a user or on its own behalf. The main roles are:
- Resource owner: the person or system that can grant access.
- Client: the application requesting access.
- Authorization server: authenticates the resource owner when needed, obtains authorization, and issues tokens.
- Resource server: the API that accepts a token and enforces access to its resources.
For example, a file-sharing app can request permission to read selected files from a user's storage provider. The storage provider issues an access token with the authority the user approved; the app does not need the user's storage password. This is the kind of delegation covered by OAuth, as in our guide to making online file sharing secure.
An access token is intended for a resource server. It may be opaque (meaning the client and API should not interpret its contents) or use a structured format such as JWT. The resource server must validate the token according to the issuer's contract; a client should not assume that it can inspect or modify an access token.
OAuth is frequently involved in “Sign in with…” buttons, but OAuth by itself describes authorization, not a standardized way for a client to verify an end user's identity. OpenID Connect Core adds that identity layer. In an OIDC flow, an ID token communicates authentication information to the client, while an access token is for a resource server. Do not send an ID token to an API as a substitute for an access token.
What a JWT does—and does not do
A JWT is a set of claims represented in a compact format. A common signed JWT is a JSON Web Signature (JWS) with a header, payload, and signature; encrypted JWTs use a different JSON Web Encryption (JWE) structure. Not every JWT has the same three-part structure.
The payload is encoded, not automatically encrypted. Anyone who obtains an ordinary signed JWT can usually read its claims. A valid signature can help a verifier detect changes, but it does not hide the claims or make the token safe to disclose. Avoid putting secrets or unnecessary personal data in a token.
A JWT format also does not tell an API what a claim means or whether the token is meant for that API. The issuer, audience, token type, expiry, signature algorithm, key source, and authorization policy all matter. “Decode and trust the JSON” is not validation.
OAuth access tokens can use JWT format when the authorization server and resource server agree on a profile. RFC 9068 defines a JWT profile for OAuth access tokens, including validation requirements. It is an optional profile: OAuth does not require every provider to issue JWT access tokens.
When to use OAuth, JWT, or both
Choose based on the problem, not the label:
- Delegated access to an API: use an OAuth flow supported by that API. Request only the scopes and resources the feature needs.
- “Sign in with” or federated login: use an OIDC flow. Keep the ID token and API access token in their intended roles.
- A token format for an OAuth API: use JWT access tokens only if the issuer supports them and local validation fits the API's trust, revocation, and key-management requirements. Otherwise, an opaque token with introspection or another server-side lookup may be a better fit.
- Internal service calls: JWT can carry claims that a service validates locally, but each service still needs a precise issuer, audience, expiry, and authorization policy. A signed JWT is not automatically safer or faster for every system.
- A single application's own session: a server-side session cookie may be simpler than introducing OAuth or JWT. Avoid adding token infrastructure unless it solves a real integration or scaling need.
JWTs can reduce the need for a resource server to contact an authorization server on every request, but that benefit comes with trade-offs. A locally verified token may remain usable until it expires unless the system adds revocation checks or another control. Opaque tokens can make central policy changes and revocation easier, at the cost of a lookup or shared state. Token size, latency, availability, privacy, and operational complexity should be part of the decision.
For a broader non-normative overview of how the technologies can work together, see WorkOS's OAuth and JWT guide. Use the relevant protocol specifications and your provider's documentation for implementation details.
A practical security checklist
The OAuth 2.0 Security Best Current Practice (RFC 9700), published in 2025, updates security guidance for OAuth deployments. For an application you build or maintain:
- Use a current authorization flow. For public clients, use the authorization code flow with PKCE (RFC 7636); RFC 9700 applies PKCE guidance to web clients as well as native apps. Use the
S256challenge method and exact registered redirect URI matching, with RFC 9700's loopback-port exception for native apps. Avoid the implicit grant for new designs, and do not use the resource-owner-password grant. - Limit what a token can do. Ask for the minimum scopes needed and restrict access tokens to the intended API audience where supported. The resource server must enforce those restrictions on each request.
- Validate tokens for the correct purpose. For a JWT access token, use a maintained library and a known issuer's keys. Check the signature against an explicit algorithm policy, the expected issuer and audience, expiration, and the token type/profile. If using the RFC 9068 profile, require its access-token type rather than accepting an ID token or an unrelated JWT.
- Protect tokens as credentials. Use TLS, keep tokens out of logs and URLs, and avoid exposing long-lived credentials to browser code. Choose token lifetimes and refresh-token protections for the sensitivity of the API; RFC 9700 requires public-client refresh tokens to be sender-constrained or rotated.
- Plan key and policy changes. Know how signing keys are published and rotated, how expired or compromised credentials are handled, and whether a locally validated JWT can be revoked quickly enough for your use case.
These are design checks, not a substitute for your identity provider's implementation guide or a security review. OAuth implementations have many options, so use the OAuth security best current practice as the current baseline rather than copying an old flow from a tutorial.
The short answer
OAuth answers how a client gets authorized access to an API. JWT answers how a set of claims can be represented. They are complementary, not alternatives: an OAuth access token may be a JWT, an opaque token, or another provider-defined format. For user sign-in, use OIDC; for API access, validate the access token according to the issuer's documented profile and the API's own authorization rules.
Cover Photo by Darlene Alderson