<div dir="ltr"><div><div class="gmail_signature">Hi all<br><br></div><div class="gmail_signature">I have a problem with direct access. I try to use similar code like is on page:<br><a href="http://keycloak.github.io/docs/userguide/html/direct-access-grants.html">http://keycloak.github.io/docs/userguide/html/direct-access-grants.html</a><br></div><div class="gmail_signature">but every time I&#39;m reciving bad request: status 400.<br><br></div><div class="gmail_signature">There is one change comparing version 1.4.0.Final with version 1.1.0.Final:<br>formparams.add(new BasicNameValuePair(OAuth2Constants.GRANT_TYPE, passwordValue));<br></div><div class="gmail_signature">I added into passwordValue password for user which was created in auth app before (not &quot;secret&quot;).<br></div><div class="gmail_signature"><br></div><div class="gmail_signature">My code looks like this:<br></div><div class="gmail_signature"><br>HttpPost post = new HttpPost(KeycloakUriBuilder.fromUri(&quot;<a href="http://IPIPIPIP:8080/auth">http://IPIPIPIP:8080/auth</a>&quot;).path(ServiceUrlConstants.TOKEN_PATH).build(realmName));<br>        List &lt;NameValuePair&gt; formparams = new ArrayList &lt;NameValuePair&gt;();<br>        formparams.add(new BasicNameValuePair(OAuth2Constants.GRANT_TYPE, passwordValue));<br>        formparams.add(new BasicNameValuePair(&quot;username&quot;, &quot;userName&quot;));<br>        formparams.add(new BasicNameValuePair(&quot;password&quot;, passwordValue));<br><br>        try {<br>               /*String authorization = BasicAuthHelper.createHeader(&quot;appNameId&quot;, secretAppName);//secretAppName<br>               post.setHeader(&quot;Authorization&quot;, authorization);*/<br>            formparams.add(new BasicNameValuePair(OAuth2Constants.CLIENT_ID, &quot;appNameId&quot;));<br>            UrlEncodedFormEntity form = new UrlEncodedFormEntity(formparams, &quot;UTF-8&quot;);<br>            post.setEntity(form);<br>    <br>            final HttpClient client = new HttpClientBuilder().disableTrustManager().build();<br>            HttpResponse response = client.execute(post);<br>            int status = response.getStatusLine().getStatusCode();<br>            HttpEntity entity = response.getEntity();<br>            if (status != 200) {<br>               throw new IOException(&quot;Bad status: &quot; + status);<br>            }<br><br></div><div class="gmail_signature">Any ideas how to solve it ?<br></div><div class="gmail_signature"><br></div><div class="gmail_signature"><i>thanks<br><br></i></div><div class="gmail_signature"><i>regards<br></i></div><div class="gmail_signature"><div><i>--</i></div><i>Emil Posmyk<br></i></div></div>
</div>