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
2
Answers
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
Have a look at this demo: keycloak-react-spring-demo, it shows how to integrate React 18 with Keycloak using a more modern JS/TS client (react-oidc-context).