[keycloak-user] Keycloak onLoad option

Kevin Marsden kevinmarsden88 at gmail.com
Tue Feb 28 13:45:19 EST 2017


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>
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
> https://lists.jboss.org/mailman/listinfo/keycloak-user


More information about the keycloak-user mailing list