I have a standalone Java application that requires a login and essentially displays a window. I’ve incorporated the Keycloak.loginDesktop() call from the examples. The Chrome browser window pops up and when I enter valid credentials, the application continues on.
My question is this: how can the application know if the user wishes to abort the login or if the user closes the browser? Then the application can exit? (I’ve looked for javadocs – no comments in the code, and looked at the code. I’ve searched for info but found nothing beyond the keycloak documents.)
My code is basically this (lifted directly from the docs):
keycloak.loginDesktop();
AccessToken token = keycloak.getToken();
// ensure token is valid for at least 30 seconds
long minValidity = 30L;
String tokenString = keycloak.getTokenString(minValidity, TimeUnit.SECONDS);
logger.warn("KEYCLOAK: token string: {}", tokenString);
Thanks,
Mark