# Handling Login Failure with KeycloakInstalled

**URL:** <https://forum.keycloak.org/t/handling-login-failure-with-keycloakinstalled/10901>\
**Category:** Securing applications\
**Tags:** authentication\
**Created:** [September 7, 2021, 8:45pm UTC](https://forum.keycloak.org/t/handling-login-failure-with-keycloakinstalled/10901 "2021-09-07T20:45:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carl](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/carl/32/10443_2.png) [@Carl](https://forum.keycloak.org/u/Carl)\
**Post date:** [September 7, 2021, 8:45pm UTC](https://forum.keycloak.org/t/handling-login-failure-with-keycloakinstalled/10901/1 "2021-09-07T20:45:23Z")

</div>

Hi,

I’m authenticating a desktop client. This code is working for me when I provide valid credentials.

```
            KeycloakInstalled keycloak = new KeycloakInstalled();
            keycloak.loginDesktop();
            AccessToken token = keycloak.getToken();

```

However, if there is a login error – even one that exceeds the Brute Force Detection – my app is still left waiting. Is there a listener or other technique that I can use to trap this condition and close out my desktop app? I’m looking for something that will work with both a max failed attempts or a closing of the browser without providing credentials.

Thanks,  
Carl
