Keycloak admin cli timeout

687 views Asked by At

I am using the Keycloak-admin-client and want to get information from a user by searching him by id.

@Service
public class KeycloakService {
    Keycloak keycloak = KeycloakBuilder.builder()
            .serverUrl("<Domain>/auth/")
            .grantType(OAuth2Constants.PASSWORD)
            .realm("Master")
            .clientId("admin-cli")
            .username("Admin")
            .password(<Password>)
            .resteasyClient(
                    new ResteasyClientBuilder()
                            .connectionPoolSize(10).build()
            ).build();

    public void getClientById(String id){
        RealmResource realmResource = keycloak.realm(<Realm name>);
        UsersResource users = realmResource.users();
        UserResource user = users.get("145a251c-8e99-426c-b3ed-068c2478efff");
        System.out.println(user.toRepresentation().getEmail());
    }
}

Using the code above I always get a timeout for the last line. The toRepresentation() call (so I am guessing the actual Api call) yields a timeout.

java.net.ConnectException: Operation timed out (Connection timed out)

I think the two important imports are:

    <dependency>
        <groupId>org.keycloak</groupId>
        <artifactId>keycloak-admin-client</artifactId>
        <version>12.0.0</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.11.0</version>
    </dependency>
0

There are 0 answers