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

Sebastien Blanc sblanc at redhat.com
Fri Sep 30 03:13:51 EDT 2016


Hard to tell without seeing whole your code but when you create your user
you don't have this issue, right ? Do you do the reset in the same "flow"
of code ?



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

> Hi Sebastien, thanks for answering.
>
> Sorry, my last message was not complete.
>
> I am trying your code but I always got a "Failed executing GET
> /admin/realms/SGCD/users: org.jboss.resteasy.spi.UnauthorizedException:
> Bearer"
>
> I tryed set the Bearer Token using the code that follows (but I do not
> have successful):
>
>        ResteasyClient resteasyClient = new ResteasyClientBuilder()
>                 .connectionPoolSize(10).build();
>         resteasyClient.target(KEYCLOAK_HOST)
>                 .register(BEARER_TOKEN);
>
>        Keycloak kc = KeycloakBuilder.builder()
>                 .resteasyClient(resteasyClient)
>                 .build();
>
>        kc.realm("SGCD").users().get(userId).resetPassword(credential);
>
> Please, you know if Is there some way for I  put my bearer token on call
> of resetPassword or on build of KeycloakBuilder?
>
> Regards,
> Maurício.
>
>
>
> ------------------------------
> *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(creden
> tials);
>
>
>
>
> On Thu, Sep 29, 2016 at 3:51 PM, Maurício Giacomini Penteado <
> 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
>> https://lists.jboss.org/mailman/listinfo/keycloak-dev
>>
>
>


More information about the keycloak-dev mailing list