Validating OAuth 2.0 Access Tokens with Ory Hydra's Token Introspection Endpoint
Learn how to validate OAuth 2.0 access tokens using Ory Hydra's token introspection endpoint, including prerequisites, request format, response checks, and recovery steps.
21 Jul 2026, 12:05 UTC

Desired outcome
Confirm that an OAuth 2.0 access token issued by Ory Hydra is still valid, active, and authorized for the required scopes before allowing a service to access a protected resource.
Prerequisites
- An operational Ory Hydra instance (version 2.x) reachable over HTTPS.
- The client ID and secret of the OAuth 2.0 client that originally issued the token.
- The access token string you want to validate.
- Ability to make HTTP POST requests (e.g., using curl or an HTTP client library).
Procedure
- Construct the introspection URL:
https:///oauth2/introspect. Replace<hydra-host>with your Hydra domain or IP. - Authenticate using HTTP Basic auth with the client ID as username and client secret as password.
- Send a POST request with a JSON body containing the token parameter:
curl -u ":" \
-X POST \
-H "Content-Type: application/json" \
-d '{"token":""}' \
"https:///oauth2/introspect"
Replace placeholders:
<client-id>– the OAuth client identifier.<client-secret>– the client secret.<access-token>– the token to validate.<hydra-host>– hostname of your Hydra deployment.
Expected checks
The server returns a JSON object. Treat the token as valid only if:
- The field
activeis present and equalstrue. - The
scopefield (space‑separated list) contains every scope required by your service. - The
client_idmatches the expected client (helps prevent token confusion attacks). - The
expclaim (Unix timestamp) is greater than the current time.
If active is missing, false, or any of the above checks fail, consider the token invalid.
Recovery options
When the introspection indicates an invalid token:
- Log the event (including token hash, client ID, and reason) for audit.
- If your application supports refresh tokens, initiate a refresh token grant to obtain a new access token.
- Return an HTTP 401 Unauthorized response to the caller, optionally with a
WWW-Authenticate: Bearerheader.
Limitations and practical verification
Introspection adds network latency and load on Hydra. To mitigate:
- Cache the introspection result for the token’s remaining lifetime (derived from
expminus a safety margin). - Ensure TLS is enabled; otherwise client credentials and token data travel in clear text.
- Avoid calling introspection on every request for high‑traffic APIs; use the cache strategy above.
You can verify the setup locally:
- Start a test Hydra instance (e.g., via Docker:
docker run -d -p 4444:4444 -e SECRETS_SYSTEM=mysecret ory/hydra:v2.0.0 serve all --dangerous-force-http). - Create a client with the client credentials grant:
hydra clients create --id test-client --secret test-secret --grant-types client_credentials --response-types token --scope offline access. - Obtain an access token:
curl -u "test-client:test-secret" -X POST "http://localhost:4444/oauth2/token" -d "grant_type=client_credentials&scope=offline". - Run the introspection command shown above with the obtained token and confirm
active:trueand the expected scopes. - Repeat with an expired token (you can manually set
expin a JWT or wait) and verifyactive:falseor missing.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.