<div dir="ltr">That looks correct to me. What status code do you get back? Any errors in the log?</div><div class="gmail_extra"><br><div class="gmail_quote">On 5 January 2016 at 07:51, PAA KOJO KONDUAH AMOS <span dir="ltr">&lt;<a href="mailto:pkkamos@gmail.com" target="_blank">pkkamos@gmail.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 lang="EN-US" link="blue" vlink="#954F72"><div><p class="MsoNormal">Hello.</p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">I am using Keycloak admin client version 1.7.0. Final to create users from an external application. I am able to create Users (with user.setEnabled set to true)and set the password as well. However, when I try to login it fails.</p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Please can anyone show me a sample code for password reset?</p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">This is what I have so far:</p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><b>URL: <a href="http://localhost:8888/auth/admin/realms/crusadersterling/users/" target="_blank">http://localhost:8888/auth/admin/realms/crusadersterling/users/</a><u></u><u></u></b></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">public void resetPassword(String userId, String token) throws IOException, Failure {</p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">                              <b>CredentialRepresentation credential = new CredentialRepresentation();<u></u><u></u></b></p><p class="MsoNormal"><b>                              credential.setType(CredentialRepresentation.PASSWORD);<u></u><u></u></b></p><p class="MsoNormal"><b>                              credential.setValue(&quot;123456&quot;);<u></u><u></u></b></p><p class="MsoNormal"><b>                              credential.setTemporary(true);<u></u><u></u></b></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">                              HttpClient client = HttpClientBuilder.create().build();</p><p class="MsoNormal">                              ObjectMapper mapper = new ObjectMapper();</p><p class="MsoNormal">                              String json = null;</p><p class="MsoNormal">                              try {</p><p class="MsoNormal">                                             String usesUrl = PropertiesUtil.getValue(&quot;reset_password&quot;);</p><p class="MsoNormal">                                             HttpPut put = new HttpPut(usesUrl + userId + &quot;/reset-password&quot;);</p><p class="MsoNormal">                                             put.addHeader(&quot;Authorization&quot;, &quot;Bearer &quot; + token);</p><p class="MsoNormal">                                             put.setHeader(&quot;Content-Type&quot;, &quot;application/json&quot;);</p><p class="MsoNormal">                                             put.setHeader(&quot;Accept&quot;, &quot;application/json&quot;);</p><p class="MsoNormal">                                             json = mapper.writeValueAsString(credential);</p><p class="MsoNormal">                                             StringEntity entity = new StringEntity(json);</p><p class="MsoNormal">                                             put.setEntity(entity);</p><p class="MsoNormal">                                             try {</p><p class="MsoNormal">                                                            HttpResponse response = client.execute(put);</p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">                                                            </p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">                                                            if (!String.valueOf(response.getStatusLine().getStatusCode()).startsWith(&quot;20&quot;)) {</p><p class="MsoNormal">                                                                           System.err.println(response.getStatusLine().getReasonPhrase());</p><p class="MsoNormal">                                                                           throw new Failure(response.getStatusLine().getStatusCode());</p><p class="MsoNormal">                                                            }</p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">                                             } catch (IOException | Failure | IllegalStateException e) {</p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">                                                            throw e;</p><p class="MsoNormal">                                             }</p><p class="MsoNormal">                              } catch (IOException e) {</p><p class="MsoNormal">                                             throw new RuntimeException(e);</p><p class="MsoNormal">                              } finally {</p><p class="MsoNormal">                                             client.getConnectionManager().shutdown();</p><p class="MsoNormal">                              }</p><p class="MsoNormal">                              </p><p class="MsoNormal">               }</p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Sent from <a href="http://go.microsoft.com/fwlink/?LinkId=550986" target="_blank">Mail</a> for Windows 10</p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,serif"><u></u> <u></u></span></p></div></div><br>_______________________________________________<br>
keycloak-user mailing list<br>
<a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br></blockquote></div><br></div>