vue-keycloak-js icon indicating copy to clipboard operation
vue-keycloak-js copied to clipboard

Always Redirect with URL #error=login_required

Open raksakaindra opened this issue 1 year ago • 3 comments

Hello, I found an issue when accessing the homepage with Keycloak auth, it always redirects to the URL #error=login_required. I'm using init like this on Vue3:

init: {
      // Use 'login-required' to always require authentication
      // If using 'login-required', there is no need for the router guards in router.js
      onLoad: "check-sso",
      silentCheckSsoRedirectUri:
        window.location.origin + "/silent-check-sso.html",
    },

The issue is similar at Stackoverflow https://stackoverflow.com/questions/73627290/react-keycloak-js-error-login-required-loop-when-accessing-home-page. The difference is on Stackoverflow using react-keycloak.

I hope this issue can be solve. Thanks

raksakaindra avatar Feb 26 '23 13:02 raksakaindra

Has any progress been made on this? We are seeing this as well. Coming to the app for the first time, home page you immediately get that error in the address bar. We are using the latest 2.2.0 version

cdecinkoKnight avatar Apr 21 '23 18:04 cdecinkoKnight

I have the same problem. Continuous loop when I use onLoad: 'check-sso'.

Can you please add an example where the function is implemented correctly? I don't want to use the Keykloack login window, but a separate form. I need to distribute the logins to different servers and realms depending on the domain.

claussma avatar Jun 27 '23 06:06 claussma

I have this problem too, but only when I access the page in chrome private window. When I access in a firefox private window it is all ok.

The error in chrome console:

Error: Failure during initialization of keycloak-js adapter
    at @dsb-norge_vue-keycloak-js.js?v=96f17145:2194:19 {error: 'login_required', error_description: undefined}

(anonymous)	@	@dsb-norge_vue-keycl….js?v=96f17145:2096
fulfilled	@	@dsb-norge_vue-keycl….js?v=96f17145:2061
Promise.then (async)		
step	@	@dsb-norge_vue-keycl….js?v=96f17145:2074
(anonymous)	@	@dsb-norge_vue-keycl….js?v=96f17145:2076
__awaiter	@	@dsb-norge_vue-keycl….js?v=96f17145:2058
install	@	@dsb-norge_vue-keycl….js?v=96f17145:2084
use	@	chunk-EYMNJ3H6.js?v=96f17145:5137
(anonymous)	@	main.ts:27

and in my main.ts file:

app.use(VueKeyCloak, {
  init: {
    // Use 'login-required' to always require authentication
    // If using 'login-required', there is no need for the router guards in router.js
    onLoad: 'check-sso',
    silentCheckSsoRedirectUri: window.location.origin + "/silent-check-sso.html"
  },
  config: {
    realm: keycloakObj.realm,
    url: keycloakObj.url,
    clientId: keycloakObj.clientId
  }
})

When I refresh the page I am in a continuous loop too.

IgorCSilva avatar Mar 06 '24 13:03 IgorCSilva