You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
keycloak.js example from the documentation leads to error path #8935
When I tried to implement the example from the documentation, namely
<html>
<head>
<script src="keycloak.js"></script>
<script>
function initKeycloak() {
var keycloak = new Keycloak();
keycloak.init().then(function(authenticated) {
alert(authenticated ? 'authenticated' : 'not authenticated');
}).catch(function() {
alert('failed to initialize');
});
}
</script>
</head>
<body >
<!-- your page content goes here -->
</body>
</html>
I consistently reached the "failed to initialize" alert.
When printing out the error code, it was coming from this line. Upon further debugging, it appears that the variable kc.messageReceiveTimeout is null, while the default timeout is supposed to be 10000. Studying the initialization, I came to the conclusion that it never gets initialized here, since this if-condition will not be fulfilled if init is not called with a non-empty options parameter. But that is what is being done in the example from the documentation.
So, this is an issue of default parameters not being initialized (or the documentation needs fixing; your team's call ;-))
Version
15.0.1
Expected behavior
I would have expected that default values are set no matter what is passed to the init function.
Actual behavior
As mentioned in the description, my code is reaching the catch statement.
How to Reproduce?
Just use your example as is from the documentation, point it to an OIDC configured client, and you should be able to reproduce.
Hello,
I have a customised theme for keycloak account management page, where we can edit user info.
So when we try to
var keycloak = new Keycloak({
authServerUrl: authUrl,
realm: realm,
clientId: 'account-console'
});
it throws error i.e. "Keycloak is not defined".
Keycloak version 24.0.1 it works fine
Keycloak version 26.0.0 this issue is happening.
Any help/suggestion would be of appreciated.
Thanks!
Activity
FlyveHest commentedon Apr 1, 2022
I can confirm that this is still an issue in 17.0.1, doing this
keycloak.init({messageReceiveTimeout: 10000});lets you actually progress using the javascript adapter.
pelepelin commentedon Feb 22, 2024
Still an issue with keycloak-js@23.
With
keycloak.init({})the defaultmessageReceiveTimeoutis properly set to 10000 ms but withkeycloak.init()it's effectively 0.This line
keycloak/js/libs/keycloak-js/src/keycloak.js
Line 167 in 5e34769
is never executed in the latter case because of this
keycloak/js/libs/keycloak-js/src/keycloak.js
Line 75 in 5e34769
Looking at the code, there are more options which suffer from the same problem.
jonkoops commentedon Feb 22, 2024
Feel free to submit a fix for this, we'll accept PRs.
29 remaining items
Allow Keycloak JS to be initialized without passing options
Allow Keycloak JS to be initialized without passing options (#33950)
Allow Keycloak JS to be initialized without passing options (keycloak…
Allow Keycloak JS to be initialized without passing options (#33950) (#…
mVirat22 commentedon Nov 11, 2024
Hello,
I have a customised theme for keycloak account management page, where we can edit user info.
So when we try to
var keycloak = new Keycloak({
authServerUrl: authUrl,
realm: realm,
clientId: 'account-console'
});
it throws error i.e. "Keycloak is not defined".
Keycloak version 24.0.1 it works fine
Keycloak version 26.0.0 this issue is happening.
Any help/suggestion would be of appreciated.
Thanks!
FlyveHest commentedon Nov 11, 2024
@mVirat22 Please read the changelog, https://www.keycloak.org/docs/latest/release_notes/index.html#keycloak-javascript-adapter-now-standalone
Your issue is not related to this at all.