Hi All,
I have two scenarios in my website. My login can be done from normal login and from backend-initiated login.
When it is normal login, I can do login with the below code in my angular project,
keycloak = new Keycloak({
url: environment.kc_url,
realm: environment.kc_realm,
clientId: environment.kc_client_id,
});
await this.keycloak
.init({
onLoad: 'login-required'
})
.then(function () {
// some code here
});
When it is a backend-initiated login, I have token already that is provided from the backend. So, I searched and found out that in the initOptions
, token
can be defined. So, I changed the code to,
await this.keycloak
.init({
token: 'access-token-here'
})
.then(function () {
// some code here
});
But it shows an error,
Failed to initialize adapter: TypeError: Cannot read properties of undefined (reading 'name')
Can anyone please help me to figure out what is wrong here or how to achieve what I am trying to do?