RFC 6749 — The OAuth 2.0 Authorization Framework
Implemented (token endpoint + /authorize via PR 297)
Source: docs/oauth/RFC_6749.md
RFC 6749 — The OAuth 2.0 Authorization Framework ¶
Status: Standards Track
Published: 2012-10
L-tier / T-tier: L0 · T2 + T5 (foundational across T0–T8)
OneAuth coverage: Implemented (token endpoint +/authorizevia PR 297)
See also:LANDSCAPE.md·RFC_oauth21.md·RFC_9700.md
In one sentence ¶
RFC 6749 is the OAuth framework — it defines the four roles, two endpoints,
and a set of grant types, plus an error-response shape that every later RFC
builds on. OAuth 2.1 doesn’t replace 6749; it constrains it.
What problem does it solve? ¶
| Without 6749 | With 6749 |
|---|---|
| Every API rolls its own delegation flow (Flickr auth, Yahoo BBAuth, Google AuthSub, the original Twitter OAuth-1.0a, vendor-specific tokens everywhere) | One framework for delegating access without sharing passwords |
| Apps store user passwords (“give me your Gmail password and I’ll fetch your contacts”) | Tokens are scoped, expirable, revocable, and never include the user’s password |
| Different apps can’t share the same identity surface; users re-enter credentials per service | One AS issues tokens that many resource servers honor |
6749 was the spec that made “Sign in with X” universal. It also has six error
codes that show up in every later OAuth RFC (invalid_request,
invalid_client, invalid_grant, unauthorized_client,
unsupported_grant_type, invalid_scope) — these are part of the framework
contract.
Relatable example ¶
When you click “Sign in with GitHub” on a third-party CI dashboard:
- You are the resource owner; the CI dashboard is the client; GitHub
is the authorization server (AS); the GitHub API is the resource
server (RS). - Your browser hits
https://github.com/login/oauth/authorize?response_type=code&...
(the AS’s/authorizeendpoint — §3.1). - After you click “Authorize,” GitHub redirects back to the CI dashboard’s
callback with?code=abc&state=xyz(auth-code grant — §4.1). - The CI dashboard’s backend POSTs that
codeto
https://github.com/login/oauth/access_token(the AS’s token endpoint —
§3.2) with its client credentials and gets back{access_token, scope, token_type}. - The dashboard calls
https://api.github.com/user/reposwith
Authorization: Bearer <token>(the RS — §7, governed by RFC 6750).
Every word in this walkthrough is 6749 terminology. Every later RFC slots
into one of those steps.
Key concepts ¶
- Four roles — resource owner, client, AS, RS. The AS+RS may be
the same server (often are); they’re separate roles, not separate processes. - Two AS endpoints —
/authorize(browser, redirect-based, §3.1) and
/token(back-channel, POST, §3.2). The split is not incidental:
/authorizeruns in front of a human;/tokenruns in front of a
machine. The security models differ. - Grant types are an open registry — 6749 ships five; every other “give
me a token” RFC plugs a newgrant_typevalue into/token. See OneAuth
coverage below for the full set. - Two client kinds — confidential (has a server backend that can hold a
secret) and public (browser SPA, mobile app — can’t keep a secret).
Confidential clients authenticate at/token; public ones use PKCE. - Refresh tokens are optional but how everything stays alive — short-lived
access tokens + long-lived refresh tokens lets you cap blast radius without
forcing the user back to the AS every hour. stateparameter is your CSRF defense — the only thing the client gets
to bind into the redirect that survives the round-trip; cite RFC 9700 §4.7
for why it’s mandatory in practice.
The five grants 6749 originally shipped (and what happened to them) ¶
| 6749 grant | Status today | OAuth 2.1 verdict |
|---|---|---|
authorization_code (§4.1) |
The workhorse — every browser/mobile login | Mandatory + PKCE required |
implicit (§4.2) |
Token returned directly to browser via redirect fragment | Removed in 2.1 — token leakage via URL |
password / ROPC (§4.3) |
Username+password sent to /token directly |
Removed in 2.1 — defeats the point of delegation |
client_credentials (§4.4) |
Machine-to-machine; no user involved | Mandatory; widely used for service auth |
refresh_token (§6) |
Trade an expiring refresh token for new access token | Mandatory + 9700 §4.14 rotation |
Plus the extension mechanism (§4.5) — grant_type=<URI> for new grants — is
how RFC 7523 (jwt-bearer), RFC 8693 (token-exchange), and RFC 8628 (device)
later plug in.
Wire example ¶
The canonical auth-code flow, post-PKCE (this is what /authorize does today
in OneAuth):
GET /authorize?response_type=code
&client_id=s6BhdRkqt3
&redirect_uri=https%3A%2F%2Fclient.example.com%2Fcb
&scope=read+write
&state=xyzABC
&code_challenge=E9Mel... ← RFC 7636 (PKCE)
&code_challenge_method=S256
HTTP/1.1
Host: as.example.com
HTTP/1.1 302 Found
Location: https://client.example.com/cb?code=SplxlOBeZQQYbYS6WxSbIA
&state=xyzABC
&iss=https://as.example.com ← RFC 9207
POST /api/token HTTP/1.1
Host: as.example.com
Content-Type: application/x-www-form-urlencoded
Authorization: Basic czZCaGRSa3F0Mzo3RmpmcDBaQnIxS3REUmJuZlZkbUl3
grant_type=authorization_code
&code=SplxlOBeZQQYbYS6WxSbIA
&redirect_uri=https%3A%2F%2Fclient.example.com%2Fcb
&code_verifier=dBjftJeZ... ← PKCE verifier
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: no-store
{
"access_token": "2YotnFZFEjr1zCsicMWpAA",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "tGzv3JOkF0XG5Qx2TlKWIA",
"scope": "read write"
}
The shape of this response — {access_token, token_type, expires_in, refresh_token, scope} — is 6749 §5.1. Every later grant returns the same
envelope.
Where it lands on the OAuth abstraction ¶
- L0 spine. 6749 is the framework; L1–L8 plug into its slots.
- T-tier: T2 + T5 primarily.
/authorizeis T2 (browser redirect);
/tokenis T5 (back-channel exchange). But 6749 also defines the redirect-
back shape (T4) and the bearer-presentation contract that 6750 fills in (T6). - 6749 is deliberately small. Most things it doesn’t specify — token format,
client auth, discovery, sender binding — were left as extension slots and
now have their own RFCs (see LANDSCAPE.md §2).
OAuth 2.0 status ¶
6749 is OAuth 2.0. Every grant, error code, endpoint, and parameter
named in this doc is part of OAuth 2.0 as published in 2012, still the
Internet Standard the production world deploys against. None of it is
deprecated. The five original grants are all still 2.0-legal.
That said, “pure 6749” is almost no one’s deployment in 2025. Real-world 2.0
ASes layer:
- RFC 6750 for the bearer-token contract (shipped same day)
- RFC 7636 (PKCE) for code-injection defense — recommended by 9700, mandatory
in many vendor profiles (Google requires it, Apple Sign-In requires it,
most modern SDKs default-on it) - RFC 9700 (Security BCP) for the accumulated wisdom
- RFC 8414 (AS Metadata) for discovery
So when this doc says “Implemented” against 6749, treat it as “the framework
contract is built”; the per-feature 2.0 vs 2.1 nuance lives in
RFC_oauth21.md.
OAuth 2.1 status ¶
OAuth 2.1 is a constraining layer on 6749 — it doesn’t replace it. The
draft removes implicit (§4.2) and ROPC (§4.3), mandates PKCE (RFC 7636) for
all auth-code exchanges, requires exact redirect URI matching, and forbids
bearer tokens in query strings. The wire is still 6749’s wire; the
requirements are tighter.
See RFC_oauth21.md for the full diff and OneAuth’s
posture, and docs/OAUTH21_ALIGNMENT.md for the
row-by-row audit.
When NOT to use it ¶
You won’t use bare 6749 in a new deployment in 2025 — you’ll layer 6750 +
7636 + 9700 on it as a minimum. But 6749 itself stays the foundation; you’re
adding defenses, not replacing the framework. Treat 6749 as the chassis, not
the finished car.
OneAuth status ¶
| 6749 surface | Status | Where (grep-verified) | Notes |
|---|---|---|---|
/authorize endpoint (§3.1, §4.1) |
Implemented | apiauth/authorize.go, apiauth/authorize_verification_handler.go, apiauth.MountAuthorize (apiauth/authorize_mount.go) |
Landed in PR 297; closes long-standing gap |
Redirect URI check at /authorize (§3.1.2) |
Implemented | apiauth/authorize.go validateRedirectURI, RedirectURIMatches |
Exact match against the registered URIs. Since 0.1.38 (issue 389) an http loopback redirect (127.0.0.1, [::1], localhost) ignores the port, as RFC 8252 §7.3 requires; scheme, host, path and query still match exactly. Since 0.1.49 a handler with neither an AppStore nor a RedirectURIValidator refuses every request unless AllowAnyRedirectURI is set (on AuthorizationHandler or AuthorizeMountConfig) |
/token endpoint (§3.2) |
Implemented | apiauth/token_endpoint.go TokenEndpointHandler.ServeHTTP (its switch req.GrantType) |
Dispatches to per-grant handler |
authorization_code grant (§4.1) |
Implemented | apiauth/authorize_granter.go AuthorizationCodeGrant (dispatched by TokenEndpointHandler.dispatchAuthorizationCode; AuthorizationCodeGrantType const in apiauth/authorize.go) |
PKCE verified at exchange (core.VerifyPKCE); exact redirect_uri match against the code’s record, both in AuthorizationCodeGrant |
| Single-use authorization codes (§4.1.2, §10.5) | Implemented | apiauth/authorize_granter.go AuthorizationCodeGrant, refuseReuse; core.AuthorizationCodeStore ConsumeAuthorizationCode / RecordAuthorizationCodeTokens |
Since 0.1.57 (issue 429) a redeemed code is marked used, not deleted, and kept until its access token expires. Presenting it again blacklists that token’s jti (only with OneAuthConfig.Blacklist set) and revokes the refresh family. A reuse racing the first redemption makes the first one refuse its tokens too. Custom stores need both methods, atomic per record |
| Registered scope (§3.3) | Implemented | apiauth/client_policy.go grantScopes, called from handleClientCredentials, handlePassword and AuthorizationHandler.ValidateValues |
With an AppStore, a scope outside AppRegistration.Scope is 400 invalid_scope on client_credentials and the password grant (0.1.48), and invalid_scope on the /authorize error redirect (0.1.49). Asking for no scope grants the registered one. A registration with no scope places no limit |
client_credentials grant (§4.4) |
Implemented | apiauth/token_endpoint.go handleClientCredentials; extractClientCredentials in apiauth/client_credentials.go |
Tokens carry client_id (0.1.48) |
refresh_token grant (§6) |
Implemented | apiauth/token_endpoint.go (handleRefresh, refreshingClient); rotates + family-revokes on reuse in apiauth/token_validator.go (RefreshGrant) |
RFC 9700 §4.14 defense built-in. A confidential owner must authenticate, and the token must belong to the presenting client_id (issue 395) |
password / ROPC grant (§4.3) |
Implemented (and slated for removal) | apiauth/token_endpoint.go handlePassword |
Off unless OneAuthConfig.PasswordGranter is set, and always off under OneAuthConfig.FAPI2 (0.1.52). TokenEndpointHandler.Lockout locks a username after repeated failures (0.1.44). OAuth 2.1 §7.6 removes ROPC; tracked under issue 294 |
implicit grant (§4.2) |
N/A — not built | — | 2.1 removes this; OneAuth never had it |
| Error response shape (§5.2) | Implemented | apiauth/token_endpoint.go TokenEndpointHandler.writeError + GrantError (apiauth/grant_errors.go) used across all grant handlers |
Returns {error, error_description} per §5.2. Wrong credentials on the password grant are 400 invalid_grant, and a refused refresh token is 400 invalid_grant (0.1.42), not 401. An invalid_client 401 carries WWW-Authenticate: Basic. A server_error logs its detail and sends “internal server error”. Malformed authorization_details on the password grant is 400, not 500, and a body over 64 KiB is 413 (0.1.48) |
| Extension grants (§4.5) | Implemented | JwtBearerGrantType, TokenExchangeGrantType, DeviceCodeGrantType all dispatched in TokenEndpointHandler.ServeHTTP |
Plugs in RFCs 7523, 8693, 8628 |
state parameter for CSRF (§10.12) |
Client-side enforced | client/browser_login.go LoginWithBrowser generates and checks it; the AS echoes it in AuthorizationHandler.SuccessRedirect / ErrorRedirect |
— |
For OAuth 2.1’s narrower contract on top of 6749, see RFC_oauth21.md.
Related RFCs ¶
- OAuth 2.1 draft — the consolidation that constrains 6749
- RFC 6750 — Bearer Token Usage; defines the
Authorization: Bearercontract 6749 §7 hands off to - RFC 7636 — PKCE; mandatory in 2.1 for every auth-code exchange
- RFC 9700 — Security BCP; the WHY behind every 2.1 restriction
- RFC 8414 — AS Metadata; how clients discover 6749 endpoints
- RFC 9207 —
isson redirect; the §4.4 mix-up defense - 6749 §4.5 — extension-grant mechanism feeds RFC 7523, 8628, 8693, OIDC CIBA
Spec links ¶
- Datatracker: rfc6749
- RFC editor copy
- Errata search (substantial — read before quoting)