set checkLoginIframe=false and then get error=login_required
See original GitHub issueI’m using @react-keycloak/ssr 3.3.0, keycloak-js 12.0.4 and nextjs 10.1.3. I have to set checkLoginIframe=false in order to initialize keycloak by access token and refresh token. However, if a user is not logged in (both refresh token and access token are empty), the page will be reloaded. Then, I get this link http://localhost:3000/#error=login_required&state=9d3ee440-4001-464d-8926-ec1985dd1359. But if I try initializing KeycloakInstance of keycloak-js by the same configuration, everything is fine. My codes
const keycloakConfig = {
clientId: process.env.NEXT_PUBLIC_KEYCLOAK_CLIENT_ID,
realm: process.env.NEXT_PUBLIC_KEYCLOAK_REALM,
url: process.env.NEXT_PUBLIC_KEYCLOAK_URL
};
return (
<SSRKeycloakProvider
keycloakConfig={keycloakConfig}
autoRefreshToken={true}
initOptions={{
// onLoad: "check-sso",
// promiseType: "native",
token: credentials.accessToken,
refreshToken: credentials.refreshToken,
checkLoginIframe: false,
enableLogging: process.env.NEXT_PUBLIC_KEYCLOAK_ENABLE_LOGGING === "true"
}}
LoadingComponent={<BackdropLoading open={true} />}
persistor={SSRCookies(cookies)}>
{/* other components */}
</SSRKeycloakProvider>
);
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:9
Top Results From Across the Web
Keycloak does not login with checkLoginIframe true, refresh ...
The error is: [KEYCLOAK] Failed to refresh token. In the network tab I can see the client sends a request to the Keycloak...
Read more >Automatic Login to Javascript Client Adapter with inital Access ...
I suppose it means that login failed somehow, however without anything like that in the server log. What could be going wrong here?...
Read more >Keycloak Refresh Issue for angular application - Google Groups
I am using keycloak JavaScript adapter in my Angular 11 app and whilst my login and redirection work, the problem is that whenever...
Read more >Chapter 2. Using OpenID Connect to secure applications and ...
If set to true , then during authentication with the bearer token, the adapter will verify whether the token contains this client name...
Read more >How to Improve Web Application Security with Single Sign-On
Web application authentication is a very important mechanism to protect ... .init({ checkLoginIframe: false, }) .then(async (authenticated) ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This error is because the version of Keycloak-js is different from your server.
Before using next auth, I had this issue and then used pure keycloak js for nextjs, I handled everything on client side, but the drawback of keycloakjs is that I cannot get the access token on server side and cannot take advantage of SSR. I havent implemented SSO for next auth yet, so you have to implement SSO feature by yourself if you really want to use next auth