lch
lch

Reputation: 2188

Keycloak unable to get access token

I'm trying to use AuthzClient to obtain an access token from a public client in my Spring app.

Here is the code:

AuthzClient authzClient = AuthzClient.create();
AuthorizationRequest request = new AuthorizationRequest();
AuthorizationResponse response = authzClient.authorization(username, password)
                                .authorize(request);
String token = response.getToken();

But I keep getting this error message:

org.keycloak.authorization.client.util.HttpResponseException: Unexpected response from server: 400 / Bad Request / Response from server: {"error":"invalid_request","error_description":"Client does not support permissions"}

Can someone please help me figure out what I'm doing wrong?

Upvotes: 2

Views: 7770

Answers (1)

Kohei TAMURA
Kohei TAMURA

Reputation: 5122

First you need to enable authorization service for your client. So you should go to your client settings page on the admin console and click the Authorization Enabled switch to ON, and then click Save button.

See also: Keycloak Authorization Services Guide - 2.3. Enabling Authorization Services

Upvotes: 6

Related Questions