79731852

Date: 2025-08-11 08:57:32
Score: 1
Natty:
Report link

Keycloak uses protocol mappers to map attributes on the user to claims in the resulting token.

If you want to map a custom, new attribute to the token, you need to configure a new protocol mapper. You do this either on a per-client basis by clicking on the client, then on its dedicated client scope and adding the mapper there or, if you want it for multiple clients, you can add a new client scope under the client scopes option, add the mapper and then add the scope to multiple clients.

Make sure to check the 'add to access token' toggle when defining the mapper.

You can find an example on how to map a custom attribute in this Baeldung tutorial.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: user25718310