[keycloak-dev] Possible BUG creating User via REST API

Maurício Giacomini Penteado mauriciogiacomini at hotmail.com
Thu Sep 29 16:23:14 EDT 2016


Hi Sebastien, thanks for answering.

I am trying your code but, I always receive a "Failed executing GET /admin/realms/SGCD/users: org.jboss.resteasy.spi.UnauthorizedException: Bearer".

Please, you know if Is there some way for I  put my bearer token on resetPassword call or on KeycloakBuilder?

I have tried using:

       ResteasyClient resteasyClient = new ResteasyClientBuilder()
                .connectionPoolSize(10).build();
        resteasyClient.target(KEYCLOAK_HOST)
                .register(BEARER_TOKEN);



________________________________
De: Sebastien Blanc <sblanc at redhat.com>
Enviado: quinta-feira, 29 de setembro de 2016 14:08
Para: Maurício Giacomini Penteado
Assunto: Re: [keycloak-dev] Possible BUG creating User via REST API

Hi Mauricio,

This is not a bug, you need to reset the password after that the user has been created, using something like :

CredentialRepresentation credentials = new CredentialRepresentation();
        credentials.setType(CredentialRepresentation.PASSWORD);
        credentials.setValue("password");

        keycloak.realm("realm").users().get(id).resetPassword(credentials);




On Thu, Sep 29, 2016 at 3:51 PM, Maurício Giacomini Penteado <mauriciogiacomini at hotmail.com<mailto:mauriciogiacomini at hotmail.com>> wrote:

Hello everybody,

All times that I create an user via REST API I have to do login on keycloak using  administrator account and have to update the credentials from user created via REST API with temporary password setted to false. Just if I do these procedures I can do login on my app using the user created via REST API.

I am using the follow code to create an user via REST API:
                .....
                CredentialRepresentation credential = new     CredentialRepresentation();
credential.setType(CredentialRepresentation.PASSWORD);
credential.setValue("test123");
credential.setTemporary(false);

UserRepresentation user = new UserRepresentation();
user.setUsername("testuser");
user.setFirstName("Test");
user.setLastName("User");
user.setCredentials(Arrays.asList(credential));
user.setEnabled(true);

Response result = kc.realm("rest-example").users().create(user);

I have setted on code false for temporary credential and user as enabled, even so, I can not do login on my application using the created user without do the procedures that I wrote at the beginning of this issue.

I think that REST API is not respecting the properties of temporary credential setted to false and user setted as enabled. It can be a BUG?

If anybody knows how can I update the credentials from a new user created via REST API leaving it able to do login on my application please let me know.

Regards,
Maurício.


_______________________________________________
keycloak-dev mailing list
keycloak-dev at lists.jboss.org<mailto:keycloak-dev at lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/keycloak-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-dev/attachments/20160929/656e8736/attachment.html 


More information about the keycloak-dev mailing list