How do I get ID of the user from KeyCloak 3.4.3 Final?

143 views
Skip to first unread message

Nick deVre

unread,
Apr 13, 2021, 9:02:37 AM4/13/21
to Keycloak User
Hi!

I am using Keycloak 3.4.3.Final. I am trying to get the ID of the user using getId() method of the class org.keycloak.representations.IDToken in my Java application, when the user is authenticated. The ID I am referring to is the ID field shown in the screen shot below. 

I tried the getId() method.  The getId() method does not return this ID value in the screenshot below. I believe the getId() returns the JWS Token value.


kuZVZ.jpg

Thank you in advance for your help.

Nick

Michal Hajas

unread,
Apr 14, 2021, 3:07:00 AM4/14/21
to Nick deVre, Keycloak User
Hello Nick,

First of all, the version of Keycloak you are using is really old, consider switching to the newest one.

Based on this: https://www.appsdeveloperblog.com/get-userid-from-keycloak-jwt-access-token/ you should be able to obtain user id from subject key.

Michal

--
You received this message because you are subscribed to the Google Groups "Keycloak User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keycloak-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/keycloak-user/ae2d0ae9-e357-4d4a-ab12-aa70faf96cc5n%40googlegroups.com.

Nick deVre

unread,
Apr 19, 2021, 11:09:28 AM4/19/21
to Keycloak User
Thank you Michal!  That worked.
Reply all
Reply to author
Forward
0 new messages