Find default realm roles using keycloak-admin-client


I’m using keycloak-admin-client 13.0.1 to:

  • validate that all current users have the right realm/client roles
  • validate that we have the correct default realm/client roles set

I was able to do the first part but I’m struggling with the second part.

The first attempt is:

Optional<RealmRepresentation> realmRepresentation = keycloak.realms()
              .filter(r -> r.getRealm().equals(this.realm))

The getDefaultRoles method is deprecated and I don’t know what replaces it. The call also returns null.

Could you please guide me on how to find the default realm/client roles via the keycloak-admin-client Java library please? Thanks!