Skip to main content

Audience for token introspection on Keycloak

Use this page when configuring the audiences of tokens introspected by a resource server to pass Keycloak's token introspection client audience check.

For an existing system, follow the migration guide to identify the affected token flows and roll out the required changes in the right order. This page provides the configuration details used by that guide.

Since Keycloak 26.6.2, the authenticated introspection client's ID must be present in the inspected access token's audience. Otherwise, introspection returns {"active": false} unless a backward compatibility exception applies.

RFC 7662 requires authentication and authorization of introspection requests, but does not prescribe this client-ID membership rule, which is specific to Keycloak.

Keycloak's temporary backward compatibility options​

Keycloak provides two temporary backward compatibility exceptions:

ScopeSetting
Server-wide--spi-login-protocol--openid-connect--allow-token-introspection-without-audience-check=true; set to false (the default) or remove to disable the exception
Introspecting clientClients → client → Advanced → OpenID Connect Compatibility Modes → Allow token introspection without audience check: On

Either exception, if effective, allows the introspection client's ID to be missing from the audience; the other introspection checks still apply. See the provider configuration reference.

Since these options are already marked as deprecated, jEAP recommends migrating to the target configuration described below, rather than relying on the exceptions.

Use the resource ID as the introspection client ID​

jEAP recommends a dedicated confidential introspection client per resource, with its client ID equal to the resource's resource-id.

A different introspection client ID would need its own entry in the inspected token's audience. Using the resource ID avoids that extra entry. In addition, separate introspection clients preserve resource-specific access and independent credential rotation.

Assigning audience scopes​

Assign audience scopes to the token-obtaining clients as described in Keycloak configuration.

If an introspected token has no aud claim, Keycloak can reconstruct the audience for its introspection client audience check. jEAP, however, validates the JWT before introspecting it. Therefore, always enable both Add to lightweight access token and Add to token introspection in the Keycloak audience mapper configuration.

Creating the introspection client in Keycloak​

See How to: create a Keycloak introspection client for a resource for the client-creation steps and the matching jEAP resource-server configuration.