Getting realm identifier from token

After a user has logged in, how do I get hold of the realm to which the user belongs? Is there a way to add this as additional information in the access token itself (like a claim or something)?

The actual use-case is that I’m using keycloak with multiple realms for a multitenancy application. After the user has logged in, the realm identifier is used to select relevant DB for the tenant to which the user belongs. It’ll be great if this information could be retried from the token itself.

That information is in the issuer claim. E.g.

 "iss": "https://<host>/auth/realms/<realm>",

Thanks a lot for the information! And for the quick reply! It works.