Hi there,

Can someone give me some hint about how to correctly setup a client that can accept REST request from a httpclient in keycloak?
For example, I use the admin-access example from keycloak source project and modify it to do a DELETE action through REST API, however I keep getting the request Forbidden 403 from keycloak server. I don’t change any setting of the admin-client imported from the json file and my code snippet of deleting user as below:

public static void deleteUser(HttpServletRequest request, AccessTokenResponse res) throws Failure {
HttpClient client = new DefaultHttpClient();
String userId = "e20277f8-2ebe-4e5e-aa00-0cee9c578249";
try {
HttpDelete delete = new HttpDelete(getBaseUrl(request) + "/admin/realms/demo/users/" + userId);
delete.addHeader("Authorization", "Bearer " + res.getToken());
HttpResponse response = client.execute(delete);
System.out.println(response.getStatusLine().getReasonPhrase());
if (response.getStatusLine().getStatusCode() != 200) {
throw new Failure(response.getStatusLine().getStatusCode());
}
HttpEntity entity = response.getEntity();
InputStream is = entity.getContent();
if (is != null)
is.close();
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
client.getConnectionManager().shutdown();
}
}