[keycloak-user] issue on user registration

daniele.capasso at dnshosting.it daniele.capasso at dnshosting.it
Thu Mar 17 10:17:45 EDT 2016


Hi, i want to register a user via keycloak admin client.

This is the source, it works except for the role, what i wrong?

CredentialRepresentation credential = new CredentialRepresentation();
credential.setType(CredentialRepresentation.PASSWORD);
credential.setValue(model.getPassword());
credential.setTemporary(false);

UserRepresentation userRepresentation = new UserRepresentation();
userRepresentation.setEmail(model.getEmail());
userRepresentation.setFirstName(model.getName());
userRepresentation.setLastName(model.getSurname());
userRepresentation.setUsername(model.getEmail());
userRepresentation.setCredentials(Arrays.asList(credential));
userRepresentation.setEnabled(true);
userRepresentation.setClientRoles(new HashMap<String, List<String>>(){{
	put(kcApi.getKeycloakCurrentClient(),Arrays.asList("ROLE_USER_HOST"));
}});

Response resp = kcApi.createUser(userRepresentation);


thank you


More information about the keycloak-user mailing list