You can check if the token was issued with the roles you defined in
On Thu, Mar 29, 2018 at 11:20 AM, Filip Kozjak <filip.kozjak(a)gmail.com>
Thank you Pedro,
indeed it was a version issue, I was using the older version of Keycloak.
However, after resolving this issue I've encountered a new one with always
getting a *401 Unauthorized* response from the service.
The client code that is calling the service is this:
*String accessToken = AuthzClient.create().obtainAccessToken.getToken();*
WebTarget target = client.target("url");
MyResponse res =
"Bearer " + accessToken)*.post(MyResponse.class);
Could the problem be something with SSL? Because my service is not
available on https:// endpoints? Or is the calling code not correct?
On 29 March 2018 at 14:07, Pedro Igor Silva <psilva(a)redhat.com> wrote:
> What version of Keycloak are you using ? Perhaps, Keycloak v4 ?
> If so, you need to make sure your keycloak-authz dependency references
> the same version.
> The uma-configuration discovery endpoint changed to uma2-configuration.
> Pedro Igor
> On Thu, Mar 29, 2018 at 4:21 AM, Filip Kozjak <filip.kozjak(a)gmail.com>
>> Hi everyone,
>> I am having troubles obtaining access token for my Java EE REST service
>> from Keycloak.
>> I have started Keycloak server at *http://localhost <http://localhost>*
>> and I can access the admin console at
>> Next, I created a new realm "demo" and registered my REST service
>> I've copied the generated *keycloak.json *to the WEB-INF of my service
>> added what was needed to web.xml. This successfully protected my
>> My REST service is up and running on *http://localhost:8080/
>> However, now I want to set up a client that would be authorized to access
>> the protected endpoint. The client is running at *http://localhost:9080
;. *Again, it's a Java EE REST service that
>> the protected service. I registered it as *OAuth Client* in the admin
>> console and again copied the *keycloak.json* to the resources of my app.
>> am trying to obtain the access token like this:
>> AuthzClient authz = AuthzClient.create();
>> AccessTokenResponse tokenResponse = authzClient.obtainAccessToken();
>> This results in the following error:
>> java.lang.RuntimeException: Could not obtain configuration from server [
>> <div id="stack">at
>> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br>at
>> 16 more<br>
>> </div>Caused by:
>> org.keycloak.authorization.client.util.HttpResponseException: Unexpected
>> response from server: 404 / Not Found<br>
>> I posted a question about it on StackOverflow too:
>> Is there something I am missing?
>> keycloak-user mailing list