Search code examples
keycloak

Setting required action on new keycloak user account


I am using a client to create a new keycloak user. Something like this:

keycloak.realm(realm)
        .users()
        .create(user);

The user variable is a UserRepresentation object, and I'm trying to add an Update Password required action:

user.setRequiredActions(singletonList("Update Password"))

User gets created ok, the problem is that I don't have the required action set

enter image description here

Not sure what I'm doing wrong, should I specify a different value in the required actions list?

Thanks


Solution

  • Figured out what was up.

    Keycloak has an enum to represent various user actions:

    public static enum RequiredAction {
        VERIFY_EMAIL, UPDATE_PROFILE, CONFIGURE_TOTP, UPDATE_PASSWORD, TERMS_AND_CONDITIONS
    }
    

    So the value should be "UPDATE_PASSWORD" not "Update password"