They answer different questions This confusion is extremely common: **JWT is a token format**. **OAuth2 is an authorization framework** — a set of flows for getting a client delegated access to a resource on a user's behalf. You can use OAuth2 without ever seeing a JWT, and you can use JWTs without any OAuth2 flow at all.
What JWT actually is A JWT (JSON Web Token) is a compact, URL-safe string with three base64url-encoded parts separated by dots: a header, a payload, and a signature. It's a **container format** for claims, nothing more. It says nothing about how the token was issued, who can request one, or what scopes mean.
What OAuth2 actually is OAuth2 is a protocol that defines **how a client obtains an access token** from an authorization server, typically after a resource owner (the user) grants consent. It defines flows like:
- Authorization Code — the standard flow for web and mobile apps
- Client Credentials — machine-to-machine, no user involved
- Refresh Token — exchanging a long-lived credential for a new access token
Critically, the OAuth2 spec does not mandate any particular token format. The access token can be an opaque random string that only the authorization server understands, or it can be a JWT. Many providers (Auth0, Okta, Google) choose JWTs because they're self-contained and verifiable without a database round trip.