RFC 7662 — OAuth 2.0 Token Introspection
Implemented (apiauth/IntrospectionHandler)
Source: docs/oauth/RFC_7662.md
RFC 7662 — OAuth 2.0 Token Introspection ¶
Status: Standards Track
Published: 2015-10
L-tier / T-tier: L2 · T7 (verify)
OneAuth coverage: Implemented (apiauth/IntrospectionHandler)
See also:RFC_9068.md·RFC_7009.md·LANDSCAPE.md
In one sentence ¶
Introspection is the RS-side mechanism to ask the AS “is this token still
valid, and what’s in it?” — the canonical alternative to local JWT
verification (RFC 9068).
What problem does it solve? ¶
| Without 7662 | With 7662 |
|---|---|
| Opaque tokens can’t be validated by anyone except the AS — RSes must call vendor-specific APIs | Standardized POST /introspect returns {active, scope, sub, exp, ...} |
| Revoked-but-not-yet-expired tokens can’t be detected by local verifiers | AS knows the live revocation state; introspection reflects it immediately |
| Multi-vendor RS deployments need N introspection client implementations | One spec; one client |
| RSes can’t authenticate themselves to introspection | Standardized — RS authenticates to AS the same way clients do |
Introspection is the path forward for opaque tokens, sender-constrained
revocation, and any RS that wants real-time revocation rather than
“trust the JWT until exp.”
Relatable example ¶
You’re building an internal API gateway that proxies to dozens of
downstream services. You want every request validated against a central
revocation list (not “trust the JWT until it expires”). You issue opaque
tokens from your AS and have the gateway call /introspect on every
request:
POST /oauth/introspect HTTP/1.1
Host: as.internal.example.com
Authorization: Basic <gateway-creds>
Content-Type: application/x-www-form-urlencoded
token=opaque-abc-123
{
"active": true,
"scope": "read write",
"client_id": "client-internal-gateway",
"username": "sri@example.com",
"exp": 1750000000,
"iat": 1749996400,
"sub": "user-42"
}
If a user clicks “revoke session,” the AS marks the token revoked
immediately; the next gateway-side introspection returns {"active": false}.
This is the fundamental difference vs JWT — JWTs are valid until exp no
matter what.
Key concepts ¶
{"active": true|false}is the universal answer. Active tokens
return additional claims; inactive ones return only{"active": false}
(RFC 7662 §2.2 — exact wording: “a JSON object with the boolean member
activeset tofalse”). Don’t leak why the token is inactive.- The caller must authenticate. Introspection reveals token contents —
only legitimate RSes (or other authorized parties) should be able to
introspect. RFC 7662 §2.1 mandates caller authentication; OneAuth uses
HTTP Basic. - Returned claims overlap with JWT claims (RFC 7519) —
iss,sub,
aud,exp,iat,nbf,jti. Plus introspection-specific:
active,scope,username,client_id,token_type. RFC 9396 RAR
tokens carryauthorization_detailsin the introspection response too. - JWT vs introspection is a deployment-time choice. They solve
overlapping problems. JWT: cheap (no AS round-trip), can’t be revoked
mid-life. Introspection: expensive (network call per request), reflects
live state. Some deployments do both (JWT + introspection cache). - Performance pattern: cache introspection results with a short TTL
(5-60s typical). Bounds revocation latency to TTL while killing the
per-request round-trip in the hot path.
Wire example ¶
Active token:
POST /oauth/introspect HTTP/1.1
Host: as.example.com
Content-Type: application/x-www-form-urlencoded
Authorization: Basic <RS-credentials>
token=2YotnFZFEjr1zCsicMWpAA&token_type_hint=access_token
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: no-store
{
"active": true,
"scope": "read write",
"client_id": "client-abc",
"username": "sri",
"token_type": "Bearer",
"exp": 1750000000,
"iat": 1749996400,
"sub": "user-42",
"aud": "https://api.example.com",
"iss": "https://as.example.com",
"jti": "abcd-1234",
"authorization_details": [
{ "type": "payment_initiation",
"actions": ["initiate"],
"instructedAmount": { "currency": "EUR", "amount": "500.00" } }
]
}
Inactive (revoked, expired, never existed — all same response):
HTTP/1.1 200 OK
Content-Type: application/json
{"active": false}
The deliberate uniformity matters — leaking “wrong token” vs “revoked” vs
“expired” would let attackers probe.
Where it lands on the OAuth abstraction ¶
- L2 lifecycle. Introspection is the runtime answer to “is this token
still good?” - T7 (verify). RS-side verification path; the alternative to local
JWT decoding. - Pairs with RFC 7009 Revocation. Revocation is the
mutation; introspection is the read.
OAuth 2.0 status ¶
Published 2015. Not part of bare 6749 but widely adopted. Major IdPs ship
introspection endpoints either:
- As a first-class feature (Auth0, Okta, Keycloak — yes)
- Or implicitly via JWT — clients verify locally and treat that as the
introspection answer (Google, GitHub — JWT-only path)
OAuth 2.1 status ¶
Not mandated by 2.1. The JWT-vs-introspection choice remains a deployment
decision. 2.1 references 7662 throughout but doesn’t require it.
In 2.1 strict deployments shipping JWTs, introspection is sometimes
omitted to avoid implementation complexity — clients verify locally with
JWKS and accept the revocation-latency tradeoff. Whether to ship
introspection is a question of how fast you need revocation to propagate.
OneAuth status ¶
| 7662 surface | Status | Where (grep-verified) | Notes |
|---|---|---|---|
POST /oauth/introspect endpoint |
Implemented | apiauth/introspection.go IntrospectionHandler.ServeHTTP, built by OneAuth.IntrospectionHTTPHandler |
RFC 7662 §2.2 compliant |
| Caller authentication via HTTP Basic | Implemented | IntrospectionHandler.ServeHTTP rejects unauthenticated callers with WWW-Authenticate: Basic realm="introspection" |
— |
{"active":false} for invalid tokens (uniform response) |
Implemented | IntrospectionHandler.ServeHTTP per §2.2 invariant |
Doesn’t leak revoked-vs-expired distinction |
| Full claim set on active tokens | Implemented | apiauth/token_introspector.go tokenIntrospector.Introspect builds the result; IntrospectionHandler.ServeHTTP writes it |
Includes scope, client_id, sub, iss, aud, jti, iat, exp |
token_type |
Implemented | tokenIntrospector.Introspect via tokenTypeFor |
Bearer, or DPoP for a key-bound token (0.1.45) |
| Refresh-token introspection | Implemented | apiauth/token_introspector.go NewTokenIntrospectorWithRefreshStore; OneAuth wires it with OneAuthConfig.RefreshStore |
A live refresh token reports active with sub, client_id, scope and exp; a revoked or expired one reports inactive. token_type_hint only picks which kind is tried first (0.1.45) |
cnf (RFC 9449 §6) in response |
Implemented | tokenIntrospector.Introspect sets IntrospectionResult.Cnf; IntrospectionHandler.ServeHTTP emits it for bound tokens only |
Missing from the HTTP response until 0.2.2 (issue 434), so a remote resource server couldn’t enforce the binding. TestIntrospection_HTTPResponseCarriesCnf |
authorization_details (RFC 9396 RAR) in response |
Implemented | IntrospectionHandler.ServeHTTP; TestIntrospection_WithRAR in apiauth/auth_rar_test.go |
— |
| W3C Trace Context (SEP-414 / issue 254) | Implemented | IntrospectionHandler.TracerProvider field; emits oneauth.introspect span with oauth.token_active attribute |
Nil-safe tracing |
| Introspection result caching | Not built-in | — | Caller’s responsibility today; could be a future helper |
When NOT to use it ¶
If your tokens are JWTs and you can tolerate “token valid until exp”
semantics, skip introspection — you save a round-trip per request, and
RFC 9068 covers the verification path locally.
You need introspection when:
- Tokens are opaque (no other validation option)
- Revocation must propagate faster than the access-token lifetime
- You’re running multiple RSes that share a centralized revocation list
- Audit/compliance requires the AS to log every token check
Related RFCs ¶
- RFC 7009 — Revocation; the mutation paired with this read
- RFC 9068 — JWT AT profile; the local-verification alternative
- RFC 6749 — the framework whose tokens this validates
- RFC 9396 — RAR; carried in introspection responses for RAR-typed tokens
- RFC 7519 — JWT claims that are shared between JWT verification and introspection