Keycloak is not maintaining session in browser

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Keycloak is not maintaining session in browser



I am using keycloak openid-connect flow. For my client app, I am using:


public class AuthenticationTest {

public static void main(String args) {

final String KEYCLOAK_JSON = Constants.KC_CONFIG_JSON_PATH;
InputStream config = Thread.currentThread().getContextClassLoader().getResourceAsStream(KEYCLOAK_JSON);
KeycloakInstalled keycloak;

try {
keycloak = new KeycloakInstalled(config);
config.close();
keycloak.loginDesktop();

AccessToken token = keycloak.getToken();
System.out.printf("UserId: %s%n", token.getSubject());
System.out.printf("Username: %s%n", token.getPreferredUsername());
System.out.printf("Email: %s%n", token.getEmail());

System.out.println(keycloak.getTokenString());
System.in.read();
} catch (IOException | VerificationException | OAuthErrorException | URISyntaxException | HttpFailure
| InterruptedException e) {
e.printStackTrace();
}
}



}



I have referred the example mentioned here: https://gist.github.com/thomasdarimont/ca16080145d226e50628d5696ffb9508



First time I launch the application, I get



"Login Successful.You may close this browser window and go back to
your console application."



However, if I relaunch my application within just 10 seconds, even without closing the previous browser window, still the login page appears instead of : you are already logged in. (The new login page is appearing in a new tab on the same window as the first login page, so it is not an issue of failure to maintain state across different windows.)



Browser: Firefox, chrome.



Any idea what I am doing wrong. Expectation is that browser must maintain a keycloak session for the same user.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

V,L srzx5B5V,4kZNvqPSUs2HFnKsA65uyX33OaWGbCh0i,tF
6OFuSNSFbKJ05 XR4X MSGL 7Cs ji,T k2JKPdTPKsdWA,WX6KC

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

Visual Studio Code: How to configure includePath for better IntelliSense results