Active Token Introspection for Authenticated LLM Requests
Active token introspection for LLM requests gives a resource server a current authorization-server decision before it routes an authenticated user or agent to a model. This guide defines the RFC 7662 request and response boundary, endpoint authentication, claim checks, caching trade-offs, fail-closed behavior, privacy controls, negative tests, and the audit evidence needed to prove that inactive tokens never reach an LLM provider.

An authenticated LLM request arrives with an access token that was valid when the authorization server issued it. The resource owner revoked that token two minutes ago. A gateway that checks only token shape or a previously cached result may still send the prompt to the model. An RFC 7662 introspection call gives the protected resource a current active result and the authorization context it needs before route policy runs.
The useful release artifact is a paired trace. On the left, the introspection response says active: false. On the right, the LLM adapter shows no provider request ID. Every intermediate component should explain that outcome without recording the bearer token.
TL;DR
- Send the token to the authorization server's protected introspection endpoint using HTTP POST, with the resource server authenticated and authorized for that endpoint.
- Require
active: true. Then validate the returned issuer and audience. Validate the token type and scope as well, along with the time bounds and client or subject context needed by the LLM route. - Bound any response cache by the token's expiration and the route's tolerance for stale revocation state.
- Treat timeout, malformed JSON, missing
active, and endpoint authentication failure as explicit closed outcomes for protected model routes.
Introspection is an authorization-server query
RFC 7662 defines a method for a protected resource to ask an OAuth 2.0 authorization server about a token's active state and associated metadata. Section 2.1 uses an HTTP POST with application/x-www-form-urlencoded data. The required token parameter carries the presented token. An optional token_type_hint can help the server locate it, but the server must extend its search when the hint fails.
The caller is the LLM resource server or an authentication gateway acting for it. The browser or API client, including an agent, should not introspect its own token and report the answer. That would make the party presenting the credential responsible for attesting to its validity.
RFC 7662 requires authorization to access the introspection endpoint so an attacker cannot scan token values. Use a dedicated resource-server identity with the narrow permission required for introspection. Keep its credential separate from model-provider credentials and from the inbound user token. Rotate it under the authorization server's client-authentication policy.
The Okta AI gateway integration guide covers the wider identity handoff. This guide owns the active check and the evidence that precedes LLM route authorization.
Active true is the start of local validation
RFC 7662 Section 2.2 makes active the one required response member. A true value generally means the authorization server issued the token and the resource owner has not revoked it. Its time window also remains valid. Section 4 requires the authorization server to perform every applicable state check, including expiry, start time, revocation, signature validation for signed tokens, and resource-server applicability.
The resource server still needs to verify that the returned authorization context fits this LLM route. Compare the returned issuer to the configured authorization server. Confirm the audience includes this protected resource when the deployment uses audience restrictions. Check the token type and scope. Check the client identity and subject according to the route contract. Apply the returned exp and nbf values where present. Reject ambiguity rather than converting a partial response into a principal.
An inactive response should contain only active: false; RFC 7662 recommends omitting extra claims to avoid exposing authorization-server state. Treat false as a normal authentication denial. Avoid telling the caller that the token was revoked, expired, unknown, or issued for another resource. The protected audit event can retain a stable local reason while the public response stays narrow.
My opinion is blunt: accepting active: true without checking the returned audience and scope turns a live status query into a green light for the wrong API.
Request construction needs credential hygiene
Send introspection requests only to a configured HTTPS endpoint associated with the trusted issuer. The inbound token belongs in the form body, never in the query string. RFC 7662 notes that POST avoids access-token leakage through server-side URL logs. Configure the HTTP client to prevent request-body logging and any redirect forwarding or debug trace that captures form fields.
Authenticate the resource server using the method agreed with the authorization server. That may be a client secret or private-key method. It may instead use a mutual TLS identity or another supported mechanism. The token under inspection and the credential authorizing introspection serve different roles. Keep them separate in code and logs. Keep them separate in metrics labels and incident procedures as well.
Bound the inbound token length before constructing the outbound request. Set connection and TLS limits. Set header, body, and total response limits. Accept the expected media type and parse one JSON object under duplicate-member handling defined by the implementation. Require active to be a Boolean member of that object. A string value such as "true" or a missing member should produce a validation failure. Conflicting duplicate members should do the same.
Limit the response fields copied into the application identity object. The authorization server may return username, sub, client_id, and scope. It may also return aud, iss, jti, and extension members. The LLM route needs a defined subset. Copying the complete response into every downstream header increases disclosure and gives unreviewed extension fields accidental authority.
Cache duration controls revocation freshness
RFC 7662 permits a protected resource to cache introspection responses. It also states the cost directly: longer caching lowers network load while increasing the risk of stale authorization information. A revoked token can remain usable while a cached active result survives. When the response includes exp, the cache must end no later than that timestamp.
Choose cache behavior per route sensitivity. A model route that can receive regulated data may call introspection for every request. A lower-risk route may accept a short cache period derived from a documented revocation objective. The cache key should be a cryptographic digest of the complete token with unambiguous framing, scoped by issuer and introspection policy. Storing the raw bearer token in a general cache or event stream creates another credential repository.
Cache active and inactive results under separate policies. A short inactive cache can reduce repeated load from a rejected token. It can also delay acceptance if an authorization server supports a state transition back to active. Document the actual server semantics before setting that duration.
The access-token audience validation guide covers the resource binding that follows a successful active check. Introspection freshness cannot repair an audience mismatch.
Endpoint failure needs a declared route result
The introspection endpoint adds a synchronous dependency to authentication. Define the outcome for DNS failure and TLS failure. Do the same for timeout, HTTP 401, and HTTP 429. Server error, malformed JSON, oversized response, and valid JSON with missing fields also need defined outcomes. For a protected LLM route, each condition should stop the request before provider dispatch. Record introspection_unavailable separately from token_inactive; an outage is an inability to establish state, while false is an authorization-server answer.
Set a total timeout that fits inside the route's request budget. Retry only conditions and methods covered by the deployment's policy. Coalesce repeat checks for the same digest when a burst arrives, but preserve the cache's freshness limit. A circuit breaker can protect the authorization server during failure. Its open state should produce the declared closed result rather than reusing an active entry beyond its approved lifetime.
Capacity planning belongs in the release evidence. Measure request volume at the expected cache setting and through the deployed connection pool. Verify that a slow introspection server applies backpressure before gateway queues consume all workers. Track latency and status by issuer policy without putting token digests or subjects into high-cardinality public metric labels. Scopes also do not belong in those labels.
Route policy follows identity resolution
A successful introspection result establishes an authenticated authorization context. The gateway then resolves that context into the local principal used by model policy. Map issuer and subject together. Attach approved tenant and role data. Retain the token's scope and audience limits. Never permit a request-body field to override the tenant or model boundary derived from trusted context.
Authentication and model authorization remain separate decisions. An active token may belong to a principal that lacks access to the requested model or region. It may also lack access to the prompt data class or route. The gateway should record a successful active check followed by a policy denial. That sequence proves the token was valid while the requested LLM action was prohibited.
Provider authentication creates another boundary in the request path. The gateway usually calls the LLM provider with a workload credential held by the server. Forwarding the inbound OAuth token to the provider can disclose it and collapse the resource-server boundary. Record the human or agent principal and the gateway workload identity as separate actors.
The identity-aware AI gateway architecture guide places that principal in the wider request path.
Negative tests should stop before model dispatch
Run the acceptance pack through the external ingress and production verifier, continuing to the policy engine and provider adapter. Use synthetic identities and a controlled model account. Include these cases:
- An active token with the expected issuer and audience reaches route policy. Its scope, time window, and subject mapping also match the expected values.
- The same token receives
active: falseafter revocation and produces no provider request ID. - An active token for another audience fails before model dispatch.
- An active token lacks the route's required scope and reaches a separate authorization denial.
- The response omits
activeor returns it as a string. Separate responses contain malformed JSON or exceed the response limit. - Endpoint authentication fails with HTTP 401 or rate limiting returns HTTP 429. The server then returns a timeout or server error.
- A cached active result is exercised before and after revocation. The measured stale window stays inside the approved policy.
- The response includes
exp, and the cache entry disappears no later than that time. - Concurrent requests for one token demonstrate the intended request-coalescing behavior. A direct provider route and any alternate gateway path are either disabled or documented as outside the acceptance claim.
Capture the request correlation ID and issuer policy. Record the token digest and endpoint identity. Add the cache state and introspection status. Include the selected response fields and principal resolution. Finish with the route decision and provider dispatch state. Redact bearer tokens and credentials. The release fails if any inactive or indeterminate token produces a model request.
Audit evidence should separate the two decisions
Create one protected event for introspection and another for LLM route policy. The introspection event records when the resource server asked and which trusted endpoint answered. It also records the cache state and active result. Include the applicable metadata checks and failure reason. The policy event records the resolved principal and route. It records the model and data classification. It also includes the policy version and allow or deny result.
Join them with an opaque correlation reference so ownership remains clear. Current token state comes from the authorization server. The resource server validates the response for its route and resolves the principal. A later LLM policy decision determines what that authenticated principal may do with this request.
The AI audit log chain-of-custody guide provides retention and custody considerations for the joined events.
DeepInspect
DeepInspect can apply identity-aware policy after an upstream resource server or authentication gateway has established the principal. For an authenticated user or agent request deliberately routed through DeepInspect's HTTP path, the policy decision can include the model destination and route. It can also include the prompt classification and tenant context, along with approved identity attributes.
The authorization server and resource-server verifier own RFC 7662 endpoint access and active-state evaluation. They also own response caching and principal resolution. DeepInspect should receive only validated identity context plus a correlation reference to that event. Its per-decision record then proves what happened at the later LLM request boundary. Direct model calls and other bypass traffic require separate controls.
Book a technical deep dive at deepinspect.ai.
Frequently asked questions
- What does active mean in an RFC 7662 response?
active: truegenerally indicates that the authorization server issued the token, its validity period permits use, the resource owner has not revoked it, and it is applicable to the protected resource making the call. The exact state tests depend on the deployment. The resource server should still validate the returned audience and scope. It should also validate the issuer, token type, and identity fields required by its route contract.- Should an LLM gateway introspect every request?
The route's revocation-freshness requirement decides. Per-request introspection gives the freshest authorization-server state and adds a network dependency. A bounded cache lowers load while creating a stale window. RFC 7662 requires any cache to end by
expwhen that field appears. Record the chosen window and test revocation inside it.- Can token introspection validate a JWT too?
Yes. RFC 7662 applies to tokens the authorization server can understand. Section 4 notes that a server may parse and validate a structured token, including its signature, before returning information. A resource server can use introspection for JWTs when current server-side state matters, even though local JWT validation is also possible under an accepted profile.
- What should happen when the introspection endpoint is unavailable?
A protected LLM route should use its documented closed outcome because token state remains unestablished. Record the condition as
introspection_unavailablerather than claiming the token is inactive. Use bounded timeouts and controlled retries. Add request coalescing and a circuit breaker. Cached results remain usable only inside their approved freshness period.- Which values should the gateway log?
Log an issuer policy ID and token digest. Record the endpoint identity and cache state. Add the active result and validated audience and scope outcome. Include the principal mapping and route decision. Finish with the correlation ID. Exclude the raw bearer token and introspection credential. Exclude unnecessary personal fields as well. Keep detailed reasons in a protected event store rather than the public authentication response.