Search code examples
reactjskeycloak

React app navigation after authentication via keycloak


I am working on a react app using keycloak authentication.I have implemented it successfully via reactkeycloakprovider. My issue is after successful authentication when I click on any of the navigation menu links for protected pages or even the dashboard page which is displayed after successful login, it seems the keycloak.login is called again. My understanding is it should not be called and should use the keycloak.authenticated flag and move on. Any ideas what could be the issue? Will share my code as needed


Solution

  • I was able to resolve it using the https://github.com/dasniko/keycloak-reactjs-demo. All other tutorials use keyclock-web which I think causes the keycloak.login to be called every time a href is clicked where as this tutorial uses keyclock-js as a service, very different from all other tutorials