RFC 6750 — OAuth 2.0 Bearer Token Usage
Implemented (header form); query-param fallback deprecated
Source: docs/oauth/RFC_6750.md
RFC 6750 — OAuth 2.0 Bearer Token Usage ¶
Status: Standards Track
Published: 2012-10
L-tier / T-tier: L0 · T6
OneAuth coverage: Implemented (header form); query-param fallback deprecated
See also:RFC_6749.md·RFC_oauth21.md·RFC_9449.md
In one sentence ¶
RFC 6750 defines the contract between the client and the resource server —
how the bearer token is presented and how the RS refuses it. It’s the wire
spec for the Authorization: Bearer <token> line you’ve typed a thousand times.
What problem does it solve? ¶
| Without 6750 | With 6750 |
|---|---|
| Every API picks its own way to carry a token (custom headers, query strings, body fields) | One standard: Authorization: Bearer <token> |
| 401 responses don’t say why — clients can’t distinguish “no token” from “expired token” from “missing scope” | WWW-Authenticate carries error= and error_description= so the client can refresh, re-auth, or escalate scope intelligently |
| Tools (proxies, gateways, clients) need to know N flavors of “is there a token here?” | One header to inspect; one challenge format to render |
6750 is the smallest of the L0 RFCs but it’s the one every resource-server
implementer touches.
Relatable example ¶
Every curl you’ve run against a modern API speaks 6750:
# GitHub
curl -H "Authorization: Bearer ghp_..." https://api.github.com/user
# Stripe
curl -u sk_test_...: https://api.stripe.com/v1/charges # 6749 §2.3.1 Basic — also valid for confidential clients
# Slack
curl -H "Authorization: Bearer xoxb-..." https://slack.com/api/auth.test
# Your own OneAuth-backed API
curl -H "Authorization: Bearer eyJhbGciOi..." https://api.example.com/me
The Bearer keyword and the response shape on a 401 are the parts 6750
contributes. Everything else is the surrounding spec stack.
Key concepts ¶
- Three transport options, only one survives 2.1.
Authorization: Bearer <token>header (§2.1) — the canonical formaccess_tokenform parameter in a POST body (§2.2) — niche, allowedaccess_tokenquery string param (§2.3) — removed by OAuth 2.1 §5.4
because tokens leak into logs, history, andRefererheaders
WWW-Authenticateis a structured response. On a 401, the RS sends:
The client parses these fields; the right code path is “refresh” notWWW-Authenticate: Bearer realm="api", error="invalid_token", error_description="The access token expired"
“make the user log in again.”- Three normative error codes at the RS (these are different from
6749’s error codes which apply at/token):invalid_request— malformed header / multiple methods usedinvalid_token— expired, revoked, bad signatureinsufficient_scope— token is valid but missing a needed scope
scope=on the challenge tells the client what scope it needs to
retry. This is how step-up scope escalation works without a back-channel.- Bearer = whoever holds it is them. This is the security property 6750
doesn’t try to fix; sender-constrained tokens (DPoP RFC 9449, mTLS RFC
8705) layer on top to add binding.
Wire example ¶
Happy path:
GET /api/me HTTP/1.1
Host: api.example.com
Authorization: Bearer 2YotnFZFEjr1zCsicMWpAA
HTTP/1.1 200 OK
Content-Type: application/json
{ "user": "sri", "scopes": ["read"] }
Expired token — RS refuses with reason:
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer realm="api",
error="invalid_token",
error_description="The access token expired"
Client reads error="invalid_token" → tries refresh-token grant → retries
with new access token. No human prompt needed.
Insufficient scope — RS asks for step-up:
HTTP/1.1 403 Forbidden
WWW-Authenticate: Bearer realm="api",
error="insufficient_scope",
error_description="Operation requires the 'write' scope",
scope="read write"
Client reads scope="read write" → restarts auth flow asking for write →
RS now accepts. This is how progressive consent works.
Where it lands on the OAuth abstraction ¶
- L0 spine. Together with 6749 it’s the minimum a real deployment ships.
- T-tier: T6. Every request the client makes to the RS is governed by 6750.
- 6750 is the slot at T6 that RFC 9449 (DPoP) and RFC 8705 (mTLS)
later compete with by adding sender binding on top.
OAuth 2.0 status ¶
6750 is OAuth 2.0’s bearer-token contract, published the same day as 6749.
All three transport options are 2.0-legal:
- Header (§2.1) — canonical
- Form body (§2.2) — niche, legal
- Query string (§2.3) — “SHOULD NOT” since publication in 2012, but
permitted with caveats. RFC 9700 §4.3.2 reinforces this against. Still
shipped in the wild today — particularly in legacy WebSocket-auth flows,
asset-URL fetches in browsers without header control, and older mobile
SDKs.
Note also that 6750’s WWW-Authenticate error-code field set (§3.1) is
under-implemented in many 2.0 deployments — most just return bare
Bearer realm=... without the structured error= / scope= fields that
let clients refresh-vs-step-up intelligently. OneAuth emits error= and
scope= since 0.1.45 (see status table below).
OAuth 2.1 status ¶
OAuth 2.1 §5 re-exports 6750 with §2.3 (the query-string form) explicitly
forbidden rather than merely discouraged. The header and body forms are
unchanged. No new error codes; no changes to WWW-Authenticate syntax.
The query-string carve-out is the only material 6750-surface delta between
2.0 and 2.1.
Migration path (query-string bearer) ¶
The deprecation is straightforward in principle, but real deployments have
legacy callers. A pragmatic on-ramp:
- Detect. Log every query-param-bearer hit with caller IP and path so
you can quantify exposure. OneAuth does this viasync.Onceto avoid
log spam (seeAPIMiddleware.credentialsinapiauth/middleware.go). - Document the alternative for each carrier scenario:
- WebSocket auth at upgrade — use the
Sec-WebSocket-Protocol
subprotocol field to carry the token, or do an initial-frame auth
handshake post-upgrade - Asset URLs in browsers — exchange the bearer for a short-lived
URL-signing ticket; carry the ticket in the URL, never the bearer - Mobile SDKs that lack header control — escalate to vendor or wrap
the HTTP client
- WebSocket auth at upgrade — use the
- Add a forced-failure mode behind a flag so callers can opt into 2.1
strictness ahead of full removal. - Remove once usage tail is zero or migration deadlines have passed.
OneAuth’s removal is tracked under issue 295 — gated on documenting the WS
alternative.
When NOT to use it ¶
- High-stakes APIs (banking, healthcare): bearer tokens replay from
anywhere they leak. Use DPoP (RFC 9449) or mTLS (RFC 8705) so the token is
bound to a sender. FAPI 2.0 mandates one of these. - WebSocket / long-lived connections: the canonical 6750 header
presentation doesn’t fit naturally with WS upgrade. Use the WS subprotocol
field or an initial-frame auth message — not the discouraged (2.0)
/ forbidden (2.1) query-string form.
OneAuth status ¶
| 6750 surface | Status | Where (grep-verified) | Notes |
|---|---|---|---|
Authorization: Bearer <token> header (§2.1) |
Implemented | apiauth/middleware.go APIMiddleware.credentials parses Bearer (case-insensitive); empty-token rejected |
Default AuthHeader is "Authorization"; overridable via APIMiddleware.AuthHeader |
WWW-Authenticate: Bearer realm=... (§3) |
Implemented | APIMiddleware.challenge, sent by APIMiddleware.handleAuthError |
Realm is hard-coded "api". Params are comma-separated (RFC 9110 §11.6.1). A request with no credentials, a malformed header or an unknown scheme gets the bare Bearer realm="api" |
| Form-encoded body param (§2.2) | Not implemented | — | Rare in practice; not on the roadmap |
| Query-param fallback (§2.3) | Opt-in only; OAuth 2.0 escape hatch | apiauth/middleware.go LegacyQueryParamBearer field with sync.Once warning |
Retained for OAuth 2.0 deployments under capability-gating umbrella #344. See docs/DEMOS.md for three header-clean WebSocket alternatives. |
error="invalid_token" on challenge |
Implemented | APIMiddleware.validateRequest |
401 with error="invalid_token" and an error_description, only when a token was presented and refused (0.1.45) |
error="insufficient_scope" + scope= |
Implemented | APIMiddleware.RequireScopes |
403 with error="insufficient_scope" and scope="<required scopes>". Before 0.1.45 a missing scope was 401 |
resource_metadata on challenge (RFC 9728 §5.1) |
Implemented | APIMiddleware.ResourceMetadataURL |
Optional. When set, every challenge carries resource_metadata="<url>" (0.1.45) |
Related RFCs ¶
- RFC 6749 — the framework that produces the token 6750 carries
- OAuth 2.1 draft — §5 re-exports 6750 with §2.3 query-param removed
- RFC 9449 — DPoP; replaces
Bearerwith sender-constrainedDPoP <token>+ proof - RFC 8705 — mTLS; binds the token to a TLS client cert
- RFC 7662 — Introspection; the RS-side companion when the token is opaque
- RFC 9068 — JWT AT profile; the shape the token has when it’s a JWT