I have secured an enterprise application with Keycloak using standard wildfly based Keycloak adapters. Issue that I am facing is that the rest web services when invoked, nee
In my case i was taking the preferred user name from the token like this
keycloakPrincipal.getKeycloakSecurityContext().getToken();
token.getPreferredUsername();
To work i had to go to keycloak and add on my client template the add builtins if not added preferred username came null.
Check the username on the built ins, client template -> mappers.
After that if worked!