Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to set user credential using Keycloak admin api

We are importing users to KeyCloak using Java code, and we are using keycloak-admin-client API.

Tried Setting password as follows , but it is not setting/persisting the password for the user.

 CredentialRepresentation credential = new CredentialRepresentation();
    credential.setType(CredentialRepresentation.PASSWORD);
    credential.setValue("password");
    userRepresentation.setCredentials(Arrays.asList(credential));

Is there other way to set user credentials

like image 880
ravthiru Avatar asked Jan 11 '17 22:01

ravthiru


1 Answers

I used following Endpoint to set the Credentials

UserResource userResource = keycloak.realm(realm).users().get(userId);
CredentialRepresentation credential = new CredentialRepresentation();
    credential.setType(CredentialRepresentation.PASSWORD);
    credential.setValue(password);
    credential.setTemporary(false);
    userResource.resetPassword(credential);
like image 70
ravthiru Avatar answered Nov 16 '22 05:11

ravthiru



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!