<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 &quot;<span>Failed executing GET /admin/realms/SGCD/users: org.jboss.resteasy.spi.UnauthorizedException: Bearer</span>&quot;.</div>
<div><br>
</div>
<div>Please, you know if&nbsp;Is there some way for I &nbsp;put my bearer token on <span style="font-family: monospace, monospace; font-size: 16px;">
resetPassword&nbsp;</span>call&nbsp;or on&nbsp;<span>KeycloakBuilder?</span></div>
<div><br>
</div>
<div><span></span>I have tried using:</div>
<div><br>
</div>
<div><span style="font-size: 12pt;">&nbsp; &nbsp; &nbsp; &nbsp;ResteasyClient resteasyClient = new ResteasyClientBuilder()</span>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .connectionPoolSize(10).build();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; resteasyClient.target(KEYCLOAK_HOST)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .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 &lt;sblanc@redhat.com&gt;<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>&nbsp;</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">&nbsp; &nbsp; &nbsp; &nbsp; credentials.setType(<wbr>CredentialRepresentation.<wbr>PASSWORD);</font></div>
<div><font face="monospace, monospace">&nbsp; &nbsp; &nbsp; &nbsp; credentials.setValue(&quot;<wbr>password&quot;);</font></div>
<div><font face="monospace, monospace">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</font></div>
<div><font face="monospace, monospace">&nbsp; &nbsp; &nbsp; &nbsp; <span class="gmail-il">keycloak</span>.realm(&quot;realm&quot;).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">&lt;<a href="mailto:mauriciogiacomini@hotmail.com" target="_blank">mauriciogiacomini@hotmail.com</a>&gt;</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 &nbsp;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>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .....</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CredentialRepresentation credential = new &nbsp; &nbsp; 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(&quot;test123&quot;)<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(&quot;testuser&quot;);</div>
<div><span style="white-space:pre-wrap"></span>user.setFirstName(&quot;Test&quot;);</div>
<div><span style="white-space:pre-wrap"></span>user.setLastName(&quot;User&quot;);</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(&quot;rest-example&quot;).<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>