[keycloak-user] Keycloak onLoad option

Andreea Ciuprina aciuprin at mpi-bremen.de
Thu Mar 2 05:12:55 EST 2017


No, I am not using Angular CLI Dev. 

I am using the React for my frontend application and Spring Boot for my backend application.



-----Original message-----
From: Kevin Marsden <kevinmarsden88 at gmail.com>
Sent: Tuesday 28th February 2017 19:45
To: Andreea Ciuprina <aciuprin at mpi-bremen.de>; keycloak-user at lists.jboss.org
Subject: Re: [keycloak-user] Keycloak onLoad option

Are you by any chance running on the Angular CLI Dev server,port 4200 ?

On Tue, Feb 28, 2017 at 8:27 PM Andreea Ciuprina <aciuprin at mpi-bremen.de <mailto:aciuprin at mpi-bremen.de> > wrote:
Hello!
 
 
 
 I am running into the following issue when using the Keycloak JavaScript adapter in order to connect our React frontend client with the Keycloak server.
 
 The following code, where the onLoad option is set to "login-required" causes the webpage to refresh every 10 seconds, after logging in:
 
 
 
 const SEC_UPDATE_TOKEN = 30;
 
 const kc: Keycloak.KeycloakInstance = Keycloak("/keycloak.json");
 kc.init({onLoad: "login-required"}).success((authenticated: boolean) => {
     if (authenticated) {
       kc.updateToken(SEC_UPDATE_TOKEN).success(() => {
           loadData();
       }).error(() => {
           alert("Failed to refresh token");
       });
     }
     else {
     // show possibly other page here...
     kc.login();
     }
 }).error(() => {
     alert("failed to initialize");
 });
 
 
 
 If I replace the onLoad option to "check-sso", the problem dissapears. 
 
 Reading the documentation, i.e. this part: 
 
 
 
 login-required will authenticate the client if the
 user is logged-in to Keycloak or display the login page if not. check-sso will only
 authenticate the client if the user is already logged-in, if the user is not logged-in the browser
 will be redirected back to the application and remain unauthenticated.
 
 was not very clear for me, regarding to the behaviour that I am observing in my case.
 
 Could you please explain me the difference between "login-required" and "check-sso" and why using one of them instead of the other in my case
 causes the unwanted, constant page refresh?
 
 Thank you!
 Best regards, 
 Andreea
 
 
 _______________________________________________
 keycloak-user mailing list
 keycloak-user at lists.jboss.org <mailto:keycloak-user at lists.jboss.org> 
 https://lists.jboss.org/mailman/listinfo/keycloak-user


More information about the keycloak-user mailing list