[keycloak-user] Fwd: User Attributes not added in token

Sandeep Rai raisandeepkmr at gmail.com
Wed May 23 12:06:17 EDT 2018


Hi Community,
Also does this depend on the database rights ? As I only have read rights
to the db. But getAttributes should just add whatever we provide as
attribute into the token ?
Regards

---------- Forwarded message ---------
From: Sandeep Rai <raisandeepkmr at gmail.com>
Date: Wed, 23 May 2018, 02:46
Subject: User Attributes not added in token
To: <keycloak-user at lists.jboss.org>


Hi Community,
I'm new to keycloak. And trying to federate login via external database.
While federating username and password validation trough JPA I'm trying to
add user attribute to the token.
To achieve that all I'm doing is adding the attribute in getAtrributes
method. As I'm expecting it then adds to the token. But after successful
validation the token I get does not have the 'phone' attribute
Is there something I'm missing ?
Do I have to add this attribute any other way ?

@Override
public Map<String, List<String>> getAttributes() {
    Map<String, List<String>> attrs = super.getAttributes();
    MultivaluedHashMap<String, String> all = new MultivaluedHashMap<>();
    all.putAll(attrs);
    all.add("phone", userEntity.getMOBILE_NO());
    return all;
}

Kind Regards


More information about the keycloak-user mailing list