I am getting HTTP 400 Bad Request
from key cloak java code while Consent Required
is set as ON
.
I am using the following code:
String realm = authenticationData.getRealm();
String clientName = authenticationData.getClientName();
String userName = authenticationData.getUserName();
String secret = authenticationData.getSecret();
String password = authenticationData.getPassword();
String authServerURL = authenticationData.getAuthServerURL();
ResteasyClient resteasyClient = new ResteasyClientBuilder().connectionPoolSize(10).register(new CustomJacksonProvider()).build();
Keycloak keycloak = KeycloakBuilder.builder()
.serverUrl(authServerURL)
.realm(realm)
.grantType(OAuth2Constants.PASSWORD)
.clientId(clientName)
.clientSecret(secret)
.username(userName)
.password(password)
.resteasyClient(resteasyClient)
.build();
String authToken = keycloak.tokenManager().getAccessToken().getToken();
I have used the following libraries in the Gradle file.
compile 'org.keycloak:keycloak-adapter-core:7.0.0'
compile 'org.keycloak:keycloak-servlet-filter-adapter:7.0.0'
compile 'org.keycloak:keycloak-authz-client:7.0.0'
compile 'org.keycloak:keycloak-admin-client:7.0.0'
compile 'org.keycloak:keycloak-core:7.0.0'
with server as Server Version 7.0.0
Note: I have tried the same code with Consent Required
set as OFF
and it works.