Create new user with Java API

Thank you for your answer. I have chosen example 2. Still receiving status 403

My code:

private final val clientId = "backend"
private final val keyCloakConfig = applicationProperties.keyCloak
private final val keycloak = KeycloakBuilder.builder()
    .serverUrl(keyCloakConfig.authServerUrl)
    .grantType(OAuth2Constants.CLIENT_CREDENTIALS)
    .realm(keyCloakConfig.realm)
    .clientId(clientId)
    .clientSecret("secret")
    .resteasyClient(
        ResteasyClientBuilder()
            .connectionPoolSize(10).build()
    ).build()!!

val response = keycloak.realm(keyCloakConfig.realm).users().create(keyCloakUser)