[keycloak-user] How to Pass User Attributes on Bearer Only Application?

Stian Thorgersen sthorger at redhat.com
Thu Nov 10 06:29:21 EST 2016

Not sure what attributes you are trying to get. Are these custom attributes
you've added to the user yourself? If so you need to add a protocol mapper
for the angular2 public client so they are added to the token. They will
then be available in otherclaims in the service.

On 8 November 2016 at 20:10, Carlos Feria <carlosthe19916 at gmail.com> wrote:

> Hi all. I have an Angular2 application(frontend) and a Restful(jax-rs) for
> rest services. My Angular2 application has a *Public Client* Configuration
> and my Rest Services has a* Bearer Only* Client Configuration. I'm trying
> to get user attributes using this code:
> HttpServletRequest request = servletRequest.get(); org.keycloak.
> KeycloakPrincipal kcPrincipal = (org.keycloak.KeycloakPrincipal) request.
> getUserPrincipal();
> org.keycloak.representations.AccessToken accessToken = kcPrincipal.
> getKeycloakSecurityContext().getToken();
> Map<String, Object> otherClaims = accessToken.getOtherClaims();
> The problem is that accessToken.getOtherClaims() doesn't return any data.
> *I
> think that this happens because my rest application is BEARER ONLY*, but
> i'm not sure.
> Please help me, *I need to pass data using user attributes (Employe
> Department for example). How could I solve my problem?*
> *Thank you very much!!!*
> --
> Carlos E. Feria Vila
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user

More information about the keycloak-user mailing list