I am getting 401 unAuthorized when im trying to delete a user.I was able to create the user with this id.And i am able to delete the user using Advanced REST Chrome client using same DELETE URL.
Can you guide what am i doing wrong here.
Thanks
*****************ERROR***********************************************************
org.springframework.web.client.HttpClientErrorException: 401 Unauthorized
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91)
at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:641)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:597)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:557)
at org.springframework.web.client.RestTemplate.delete(RestTemplate.java:429)
at com.snrapps.mwp.domain.security.KeyCloakAdminAdapter.deleteUser(KeyCloakAdminAdapter.java:256)
at com.snrapps.mwp.domain.security.KeyCloakAdminAdapter.main(KeyCloakAdminAdapter.java:55)
*****************CODE**************************************************************
public boolean deleteUser(String userId) {
AccessTokenResponse accessTokenResponse = getToken();
org.springframework.http.HttpEntity<String> entity = new org.springframework.http.HttpEntity<String>(getHeaders(accessTokenResponse.getToken()));
HttpHeaders httpHeaders=entity.getHeaders();
System.out.println(httpHeaders);
RestTemplate restTemplate = new RestTemplate();
String urlForDeleteUser = "http://XXXXX.com:XXXX/auth/admin/realmsMyAppsRealm/users/" + userId;
System.out.println(urlForDeleteUser);
restTemplate.delete(urlForDeleteUser, entity);
System.out.println("done");
return true;
}
_______________________________________________ keycloak-user mailing list keycloak-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/keycloak-user