[keycloak-user] Direct access (keycloak migration from 1.1.0 to 1.4.0)

Emil Posmyk emil.posmyk at gmail.com
Thu Aug 6 11:40:17 EDT 2015


Hi all

I have a problem with direct access. I try to use similar code like is on
page:
http://keycloak.github.io/docs/userguide/html/direct-access-grants.html
but every time I'm reciving bad request: status 400.

There is one change comparing version 1.4.0.Final with version 1.1.0.Final:
formparams.add(new BasicNameValuePair(OAuth2Constants.GRANT_TYPE,
passwordValue));
I added into passwordValue password for user which was created in auth app
before (not "secret").

My code looks like this:

HttpPost post = new HttpPost(KeycloakUriBuilder.fromUri("
http://IPIPIPIP:8080/auth
").path(ServiceUrlConstants.TOKEN_PATH).build(realmName));
        List <NameValuePair> formparams = new ArrayList <NameValuePair>();
        formparams.add(new BasicNameValuePair(OAuth2Constants.GRANT_TYPE,
passwordValue));
        formparams.add(new BasicNameValuePair("username", "userName"));
        formparams.add(new BasicNameValuePair("password", passwordValue));

        try {
               /*String authorization =
BasicAuthHelper.createHeader("appNameId", secretAppName);//secretAppName
               post.setHeader("Authorization", authorization);*/
            formparams.add(new
BasicNameValuePair(OAuth2Constants.CLIENT_ID, "appNameId"));
            UrlEncodedFormEntity form = new
UrlEncodedFormEntity(formparams, "UTF-8");
            post.setEntity(form);

            final HttpClient client = new
HttpClientBuilder().disableTrustManager().build();
            HttpResponse response = client.execute(post);
            int status = response.getStatusLine().getStatusCode();
            HttpEntity entity = response.getEntity();
            if (status != 200) {
               throw new IOException("Bad status: " + status);
            }

Any ideas how to solve it ?



*thanks*

*regards*
*--*

*Emil Posmyk*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-user/attachments/20150806/9face888/attachment.html 


More information about the keycloak-user mailing list