jwtkeycloakkeycloak-serviceskeycloak-rest-api

Why the buildin claims not shown in JWT from the default client “admin-cli” in Keycloak?


In keycloak, there is a default client which client id is “admin-cli”. I try to add a buildin claim into this client.

In Mappers tab under this client, I add buildin mapper “realm roles”. But when I get the JWT from this client using the API:

http://{{url}}/auth/realms/{{realm}}/protocol/openid-connect/token

with proper client_id, the JWT doesn’t include the claim.

I created another client and add the same mapper with same configuration, JWT requested from that client includes the claim.

Any idea why the claim not shown in JWT from client “admin-cli” ?


Solution

  • Any idea why the claim not shown in JWT from client “admin-cli” ?

    Old Keycloak UI

    Yes, you need to:

    enter image description here

    This will make all the Realm and Client roles to show up on the Token. If you only need some specific roles then do the following:

    enter image description here


    New Keycloak UI

    Yes, you need to:

    enter image description here

    This will make all the Realm and Client roles to show up on the Token. If you only need some specific roles then do the following:

    enter image description here