I would like to use the admin client to update a user in order to force him to change his password next time he logs in ?
So far i have failed miserably to do it so i was wondering if this is at all possible ?
Keycloak keycloak = Keycloak.getInstance(authServer, "example", "examples-admin-client", "password", "examples-admin-client", "password");
RealmResource realm = keycloak.realm("example");
UsersResource users = realm.users();
List<UserRepresentation> users_ = users.search("", 0, 1000000); // This gets me all my users
for (UserRepresentation user_ : users_) {
if (user_.getUsername().equals("examples-admin-client")) {
user_.setEmailVerified(true);
}
}
RealmRepresentation realm_ = realm.toRepresentation();
realm_.setUsers(users_);
realm.update(realm_);
Thanks for any help on this.