I wanna get groups of given user.
I have try with Java admin SDK, but it return null:
var serverUrl = "http://localhost:8080";
var realm = "<real>";
var clientId = "<client_id>";
var clientSecret = "<client_secret>";
var keycloak = KeycloakBuilder.builder()
.serverUrl(serverUrl)
.realm(realm)
.grantType(OAuth2Constants.CLIENT_CREDENTIALS)
.clientId(clientId)
.clientSecret(clientSecret)
.build();
var realmResource = keycloak.realm(realm);
var userResource = realmResource.users();
var user = userResource.searchByEmail("<email>", true).get(0);
var groups = user.getGroups(); // => null
I search in the API docs and found that there is an API GET /{realm}/users/{id}/groups
but don’t found the corresponding API in Keycloak SDK
https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html#_groupmembership