User IP inside JWT

Hello, community.

How I can get user IP inside JWT?

I have a task to extend JWT by custom fields. The most confusing field displays user IP inside the payload. I do it through admin REST inside OIDC. After get JWT I going inside a keycloak, catch user IP by session. Then insert it inside the session. But it looks like a bad decision.

Please advise me on how I can do it highly correctly. If I should change source code, every advice will be best.

Thank u

How I catch IP:
url --location --request GET ‘’ --header ‘Authorization: bearer’ | | jq ‘.[0].ipAddress’

Hello, I have a similar requirement, did you ever figure out another way of passing IP into the JWT?

You could create a custom even listener and add the ip address on a login event as a user attribute.
An example can be found on