The question OAuth answers is not who this user is, but what this application is allowed to do with which resource.
Passwordless Delegation
Suppose a scheduling app reads a user's Google Calendar to suggest meeting times. Without a delegation standard, the simplest approach is for the app to collect the Google ID and password directly. It works, but the trust being handed over is far too broad.
The app has to store the password. Without a way to grant read-only calendar access, the user surrenders full account credentials. A breach of that one app puts the Google account at risk, and revoking access for a single app is difficult. If Google introduces multi-factor authentication (MFA) or a new login method, every third-party flow breaks along with it.
OAuth lets the user delegate a limited permission, such as reading the calendar, through a separate credential. The user authenticates with Google directly and approves the app's request. The app receives an access token rather than a password. In this arrangement the app needs to know neither the password nor the details of the MFA process.
The four parties are roles, not products
OAuth terminology feels dense because the names describe roles rather than products.
| Role | Example | What it does |
|---|---|---|
| Resource Owner | The user | The party that can grant access to a protected resource |
| Client | The scheduling app | The application that accesses the API on the user's behalf |
| Authorization Server | Google's authorization server | Authenticates the user, collects consent, issues tokens |
| Resource Server | Calendar API | Validates tokens and serves protected resources |
The Client here is the application, not the browser and not the person. One company may run both the Authorization Server and the Resource Server, but the responsibilities remain logically separate.
sequenceDiagram
actor U as User
participant C as Client(calendar app)
participant AS as Authorization Server
participant RS as Resource Server(Calendar API)
U->>C: Choose to connect the calendar
C->>AS: Request calendar read permission
AS->>U: Login and consent prompt
U->>AS: Approve
AS-->>C: Issue a scoped access token
C->>RS: Request events with the access token
RS-->>C: Return the permitted calendar data
The sequence diagram walks the delegation from the initial request through to resource access. User credentials never reach the Client at any step. Authentication happens entirely inside the Authorization Server, and the Client receives only the resulting token.
That arrangement separates three things. Credentials are separated from the app, so a compromised app does not immediately expose the login password. Account authority is separated from delegated authority, so a calendar read token cannot delete Drive files. Lifetime and revocation are separated as well, so a user can cut off one app without changing the password.
Access token, scope, audience, refresh token
An access token is the credential the Client presents when requesting a resource from the Resource Server. The standard location for it is the Authorization header.
GET /calendar/events HTTP/1.1
Host: api.example.com
Authorization: Bearer mF_9.B5f-4.1JqMBearer means whoever presents it can use it. RFC 6750 defines a bearer token as one usable through possession alone, with no separate cryptographic proof of key ownership. An attacker holding a copy can use it. TLS, short lifetimes, and safe storage are therefore preconditions. OAuth does not dictate whether the token is a JWT or an opaque string; the Resource Server and Authorization Server agree on a validation method.
A scope is a string describing the requested access. Providers define both the names and their meanings, so identical names do not imply identical semantics. The OIDC scopes openid, profile, and email relate to identity information, not to Gmail read access.
scope=calendar.read calendar.event.createIf scope answers "what", audience answers "where". A token issued for the Calendar API must be rejected by a payments API. RFC 8707 defines how a Client names the target resource through the resource parameter. The Resource Server has to verify that the token it received was issued for itself. Skip that check and a token accepted by one server gets replayed against another.
Refresh tokens bridge the gap between short access token lifetimes and user convenience. They are never sent to a Resource Server, only to the Authorization Server's token endpoint. Frequently quoted values such as a ten-minute access token and a thirty-day refresh token are implementation examples, not part of the standard.
Where OAuth ends and login begins
OAuth by itself does not tell the Client who the user is. OpenID Connect (OIDC) standardizes that, layering authentication on top of OAuth 2.0.
| Question | OAuth 2.x | OpenID Connect |
|---|---|---|
| Purpose | API authority delegation | User authentication |
| Consumed by | Resource Server | Client |
| Primary token | Access token | ID token |
| Core content | Scope, audience, permissions | User identifier, authentication time, issuer |
When the Client includes the openid scope in the authorization request, the OpenID Provider issues an ID token. The Client validates the ID token and uses it to establish a user session, while the access token goes to the API. Swapping their purposes is a mistake.
A common error is needing only login, then calling some arbitrary API with the access token to infer who the user is. The correct approach is validating the ID token signature along with iss, aud, exp, and nonce.
The narrow boundary PKCE defends
The Authorization Code flow splits communication into a front channel that passes through the browser and a back channel between servers. Only the authorization code, which is short-lived and single-use, is exposed in browser redirects. The actual access token is delivered to the Client in the token endpoint response.
The difficulty is public clients. Mobile apps, desktop apps, SPAs, and local AI clients all ship code the user owns. A static client_secret cannot stay secret. A fixed secret embedded in a binary or in JavaScript is extractable by an attacker and therefore proves nothing about the Client's identity.
That is where code interception becomes possible. On mobile operating systems, a custom URI scheme such as myapp://callback can be claimed by multiple apps. The legitimate app starts the authorization flow, and the user approves. A malicious app intercepts the callback, obtains the code, and submits it to the token endpoint. If the code alone is enough to redeem, the attacker gets the access token.
PKCE, defined in RFC 7636, generates a fresh one-time secret per authorization request and binds redemption to whoever made the request.
code_verifier = sufficiently long high-entropy random string
code_challenge = BASE64URL(SHA256(code_verifier))
code_challenge_method = S256Only the challenge is sent in the authorization request, and the Authorization Server stores it alongside the issued code. At the token endpoint, the Client submits the original verifier. The server hashes it with SHA-256 and compares the result against the stored challenge. An attacker who stole the code does not have the original verifier, so redemption fails.
PKCE and state are frequently conflated. Their purposes and their validators differ.
| Value | Primary purpose | Validated by |
|---|---|---|
code_verifier / code_challenge | Defends against code interception and injection, binds redemption to the requesting Client | Authorization Server |
state | Correlates request and response, defends against CSRF | Client |
OIDC nonce | Binds the ID token to the login transaction | OIDC Client |
Using PKCE is not by itself a reason to drop state validation. RFC 9700 lets a Client rely on the CSRF protection of PKCE only if the Client has ensured that the Authorization Server supports PKCE. In OIDC flows, nonce provides CSRF protection. Otherwise, state must carry a one-time CSRF token that is securely bound to the user agent.
PKCE protects exactly one boundary, the point where an authorization code becomes a token. Protecting tokens after issuance is the job of storage, lifetime, audience, and sender constraining. XSS in the browser runtime, tokens accidentally written to logs, and over-broad scope approval are all outside PKCE's range.
What OAuth 2.1 dropped
As of 2026-12, OAuth 2.1 is not a final RFC but an Internet-Draft targeting the Standards Track. The most recent document is draft-17, published 2026-10-31. The IETF Datatracker still lists it as an OAuth working group document.
Draft-17 lists RFC 6749 and RFC 6750 as documents that it obsoletes. That entry carries the condition if approved, and it has no effect until the draft is published as an RFC. Saying OAuth 2.1 has already obsoleted 2.0 is therefore inaccurate. It is better described as an ongoing effort to consolidate and replace the two RFCs against modern security expectations.
The stable baseline you can apply today is RFC 9700, Best Current Practice for OAuth 2.0 Security, published in 2025.
The direction is not adding features but removing dangerous options.
| Area | What OAuth 2.0 allowed | The OAuth 2.1 draft (draft-17) baseline |
|---|---|---|
| Authorization Code | Code flow without PKCE | PKCE integrated into the base flow, plain method removed |
| Implicit Grant | response_type=token | Removed from the specification |
| Password Grant | ROPC defined | Removed from the specification |
| Redirect URI | Loose pattern matching in practice | Exact string comparison, except the loopback port for native apps |
| Bearer token transport | Query string form also defined | Query transport removed from the specification |
| Refresh tokens for public clients | Weak reuse prevention | Single use or sender constrained |
The plain method, from RFC 7636, sends the code_verifier in the authorization request without transforming it. Draft-17 forbids it. S256 is the only transformation that the draft defines.
The draft's PKCE requirement has an exception. It applies only to a confidential client. In the specific deployment and request, the Authorization Server must also have reasonable assurance that the client implements the OIDC nonce properly. The server may then choose not to enforce PKCE, but using and enforcing PKCE is still recommended.
The Implicit Grant put the access token directly in the authorization response, with no token endpoint exchange. Once a token appears in the browser layer, URL handling, misdirected redirects, extensions, and history all become exposure paths. No standard method binds an access token issued in the authorization response to a Client, so sender constraining cannot be applied. Code reuse detection is also hard to apply.
The Password Grant has the Client collect the user's ID and password directly and submit them. That contradicts OAuth's founding premise of separating passwords from clients. It also makes it impractical for a Client to handle modern authentication such as phishing-resistant MFA, WebAuthn, or federation with an external identity provider.
The idea that PKCE replaces client_secret also needs correcting. Client authentication proves the caller is a registered confidential client. PKCE proves that the Client instance that started this authorization request is the one redeeming the code. They protect different boundaries, so server-side clients use both.
Issuing refresh tokens to public clients requires some mechanism to detect reuse. Rotation invalidates the old token on refresh and issues a new one. If an invalidated token is presented again, the Authorization Server treats that as a theft signal and revokes the active refresh token. Under draft-17, it also revokes the authorization grant associated with that token.
RT-1 used → AT-2 + RT-2 issued → RT-1 invalidated
RT-1 reuse detected → theft signal → token family revokedThe other option is sender constraining. The token is bound to a key or certificate the Client holds, so an attacker who copied only the string cannot produce the key proof. The main mechanisms are mTLS (RFC 8705) and DPoP (RFC 9449).
The OAuth 2.1 draft does not mandate DPoP for every access token, though. Sender constraining is recommended (SHOULD) for access tokens. What the draft requires (MUST) is rotation or sender constraining for public client refresh tokens.
SPAs, BFF, and MCP
Even after PKCE, an issued token has to live somewhere. If browser JavaScript holds the access token, XSS can read it and exfiltrate it. In SPA design the important question is not only which flow to use, but which process and which storage the token lives in.
The Backend for Frontend (BFF) pattern moves the token out of the browser. A dedicated backend acts as the OAuth client, redeems the code, and keeps tokens server side. The browser receives only a session cookie with HttpOnly and Secure attributes and an appropriate SameSite policy.
flowchart LR
B[Browser SPA] -->|HttpOnly Secure Cookie| F[BFF]
F -->|Authorization Code + PKCE| AS[Authorization Server]
AS -->|Access / Refresh Token| F
F -->|Bearer Token| API[Resource Server]
Only cookies travel between the browser and the backend, while real tokens exist only between the BFF and the authorization and resource servers. This layout substantially reduces the risk of a script reading and exporting the raw token. XSS itself does not go away, however. Malicious script can still issue requests from the user's browser that carry the session cookie automatically. CSP, output encoding, CSRF defenses, and re-authentication for sensitive operations remain necessary.
The Model Context Protocol (MCP) adds a new condition. An MCP client connects to servers it has never seen before, dynamically at runtime. Unlike deployments that assume static configuration, it must discover the authorization server location and endpoints, the supported scopes, and the token audience on the fly.
The MCP Authorization specification (2026-07-28) is the current revision as of 2026-12. It solves this by combining existing standards and drafts rather than inventing a protocol. The OAuth 2.1 document that this revision references is draft-13, not draft-17.
| Purpose | Standard or draft |
|---|---|
| Resource Server publishes its authorization server location | RFC 9728 Protected Resource Metadata |
| Discovery of authorization and token endpoints | RFC 8414 Authorization Server Metadata or OpenID Connect Discovery 1.0 |
| Defense against authorization code interception | RFC 7636 PKCE (applied through the OAuth 2.1 draft) |
| Restricting the token audience | RFC 8707 Resource Indicators |
| Identifying the authorization server that sent the authorization response | RFC 9207 Authorization Server Issuer Identification |
| Registering a client with no prior relationship | Client ID Metadata Documents (Internet-Draft) |
| Backward compatibility with authorization servers that do not support the method above | RFC 7591 Dynamic Client Registration (deprecated) |
The 2026-07-28 revision makes Dynamic Client Registration deprecated. It directs new implementations to Client ID Metadata Documents. With Client ID Metadata Documents, the client uses an HTTPS URL as its client_id. The authorization server reads a JSON document with the client information from that URL.
For clients that support all methods, the client registration document recommends (SHOULD) a priority order. The order is pre-registered information, Client ID Metadata Documents, Dynamic Client Registration, and then user input.
Dynamic Client Registration is not removed yet. It remains optional (MAY) for backward compatibility with authorization servers that do not support Client ID Metadata Documents. According to the deprecated features registry, it becomes eligible for removal, at the earliest, in the first revision released on or after 2027-07-28.
The same revision also adds iss validation from RFC 9207. Authorization servers SHOULD include iss in authorization responses. If iss is present, the client MUST compare it with the recorded issuer before it sends the authorization code to a token endpoint.
If the authorization server advertises iss support in its metadata but the response has no iss, the client rejects the response. If support is not advertised and iss is absent, the client proceeds. This validation is a defense against mix-up attacks. In a mix-up attack, an attacker-controlled authorization server makes the client send it a code or token that a different authorization server issued.
Audience restriction matters especially in AI agent architectures where one client attaches to many resource servers. If a calendar token also passes at the payments API, you get confused deputy and token passthrough problems.
Finally, OAuth's limits should be stated plainly. OAuth does not judge whether an agent's behavior is safe. An agent holding entirely valid tokens can still be tricked by prompt injection into calling a dangerous tool.
Controls have to be layered: minimal per-tool scopes, and separate scopes for read, write, payment, and delete. High-risk operations need step-up authentication. Tokens must never be placed in model context or tool results.
Summary
OAuth is not a login technology but a shared language for passing along trust that is limited in scope, audience, and lifetime, without handing over a password. The OIDC ID token tells the Client who the user is. The access token covers API access only. Keep these roles separate.
PKCE guards the exchange of an authorization code for a token. After issuance, storage, logging, and audience validation need separate controls. As of 2026-12, OAuth 2.1 is still a draft, so RFC 6749 and RFC 6750 are not yet obsoleted. Its direction is unambiguous, however: drop the Implicit and Password grants and promote PKCE to the default. In practice it is more useful to check whether controls actually sit on the four boundaries of issuance, storage, use, and discovery than to chase the 2.1 label.