<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p><br>
</p>
Hi Sebastien, <span>thanks for answering.</span>
<div><br>
</div>
<div>I am trying your code but, I always receive a "<span>Failed executing GET /admin/realms/SGCD/users: org.jboss.resteasy.spi.UnauthorizedException: Bearer</span>".</div>
<div><br>
</div>
<div>Please, you know if Is there some way for I put my bearer token on <span style="font-family: monospace, monospace; font-size: 16px;">
resetPassword </span>call or on <span>KeycloakBuilder?</span></div>
<div><br>
</div>
<div><span></span>I have tried using:</div>
<div><br>
</div>
<div><span style="font-size: 12pt;"> ResteasyClient resteasyClient = new ResteasyClientBuilder()</span>
<div> .connectionPoolSize(10).build();</div>
<div> resteasyClient.target(KEYCLOAK_HOST)</div>
<div> .register(BEARER_TOKEN);</div>
<div><br>
</div>
<br>
<span></span>
<div><br>
<div style="color: rgb(0, 0, 0);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>De:</b> Sebastien Blanc <sblanc@redhat.com><br>
<b>Enviado:</b> quinta-feira, 29 de setembro de 2016 14:08<br>
<b>Para:</b> Maurício Giacomini Penteado<br>
<b>Assunto:</b> Re: [keycloak-dev] Possible BUG creating User via REST API</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div>Hi Mauricio,<br>
<br>
</div>
This is not a bug, you need to reset the password after that the user has been created, using something like :
<br>
<br>
<font face="monospace, monospace">CredentialRepresentation credentials = new CredentialRepresentation();</font>
<div><font face="monospace, monospace"> credentials.setType(<wbr>CredentialRepresentation.<wbr>PASSWORD);</font></div>
<div><font face="monospace, monospace"> credentials.setValue("<wbr>password");</font></div>
<div><font face="monospace, monospace"> </font></div>
<div><font face="monospace, monospace"> <span class="gmail-il">keycloak</span>.realm("realm").users(<wbr>).get(id).<span class="gmail-il">resetPassword</span>(<wbr>credentials);<br>
<br>
<br>
</font></div>
<br>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Thu, Sep 29, 2016 at 3:51 PM, Maurício Giacomini Penteado
<span dir="ltr"><<a href="mailto:mauriciogiacomini@hotmail.com" target="_blank">mauriciogiacomini@hotmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr">
<div style="font-size:12pt; color:#000000; font-family:Calibri,Arial,Helvetica,sans-serif">
<p></p>
<div><span style="font-size:12pt">
<div>Hello everybody,</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>I am using the follow code to create an user via REST API:</div>
<div> .....</div>
<div> CredentialRepresentation credential = new CredentialRepresentation();</div>
<div><span style="white-space:pre-wrap"></span>credential.setType(<wbr>CredentialRepresentation.<wbr>PASSWORD);</div>
<div><span style="white-space:pre-wrap"></span>credential.setValue("test123")<wbr>;</div>
<div><span style="white-space:pre-wrap"></span>credential.setTemporary(false)<wbr>;</div>
<div><br>
</div>
<div><span style="white-space:pre-wrap"></span>UserRepresentation user = new UserRepresentation();</div>
<div><span style="white-space:pre-wrap"></span>user.setUsername("testuser");</div>
<div><span style="white-space:pre-wrap"></span>user.setFirstName("Test");</div>
<div><span style="white-space:pre-wrap"></span>user.setLastName("User");</div>
<div><span style="white-space:pre-wrap"></span>user.setCredentials(<span>Arrays.</span>asL<wbr>ist(credential));</div>
<div><span style="white-space:pre-wrap"></span>user.setEnabled(true);</div>
<div></div>
<div><br>
</div>
<div></div>
<div><span style="white-space:pre-wrap"></span>Response result = kc.realm("rest-example").<wbr>users().create(user);</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>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?</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>Regards,</div>
<div>Maurício.</div>
</span></div>
<br>
<p></p>
</div>
</div>
<br>
______________________________<wbr>_________________<br>
keycloak-dev mailing list<br>
<a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/keycloak-dev</a><br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>