Hardcoded Attribute Mapper doesn't work with External to Internal token exchange

Hi!
I want to add some hardcoded user attributes to a new imported user, when i call external to internal token exchange service. It doesn’t work when user is importing to internal realm, and it works when user is already exists. I think it happens because of missing importNewUser method in HardcodedAttributeMapper. The method should be like:

@Override
public void importNewUser(KeycloakSession session, RealmModel realm, UserModel user, IdentityProviderMapperModel mapperModel, BrokeredIdentityContext context) {
    String attribute = mapperModel.getConfig().get(ATTRIBUTE);
    String attributeValue = mapperModel.getConfig().get(ATTRIBUTE_VALUE);
    user.setSingleAttribute(attribute, attributeValue);
}

Have any ideas about it?

Hello,

I am facing the exact same issue. Did you find a solution to your issue in the meanwhile?

1 Like