import org.keycloak.KeycloakPrincipal; import org.keycloak.KeycloakSecurityContext; import org.keycloak.representations.IDToken; ... @Resource private SessionContext sessionContext; ... @SuppressWarnings("unchecked") KeycloakPrincipal<KeycloakSecurityContext> kcPrincipal = (KeycloakPrincipal<KeycloakSecurityContext>)(sessionContext.getCallerPrincipal()); IDToken idToken = kcPrincipal.getKeycloakSecurityContext().getIdToken(); log.debug( "email from token is \"" + idToken.getEmail() + "\"" );
ThanksI dont know how to get info from the accesToken, or does the access token class already has methods to do that. I know this is more of a question of design. This part is not really clear for me.I have a backend with java that should connect to my keycloak server once it gets the tokenHiI want to be able to update the user password and some preferences from my web app, in order to update some of the user info from my portal i can see in the rest api that you need the user ID.
KeycloakSecurityContext securityContext = (KeycloakSecurityContext) httpRequest
.getAttribute(KeycloakSecurityContext.class.getName());
AccessToken accessToken = securityContext.getToken();
_______________________________________________ keycloak-user mailing list keycloak-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/keycloak-user