I am trying to implement a feature where the user logs directly to our portal.
I am getting the user's access token and refresh using the admin's credentials.
I tried initiating the session in the following way:
keycloak.init({
token: userInfo.access_token,
refreshToken: userInfo.refresh_token,
checkLoginIframe: false,
}).then((authenticated) => {
// console.log('authenticated', authenticated, keycloak);
this.setState({ keycloak });
this.setState({ authenticated });
if (authenticated) {
keycloak.login({
clientId: 'process.env.clientId',
redirectUri: 'http://localhost:3003/',
prompt: 'none',
scope: 'openid profile',
}).then(res => console.log(res)).catch(err => console.log(err));
}).catch(err => console.log('Error initiating keycloak', err));
Using the above code I was able to get the create a session and get authenticated, but not able to set the cookies and manage a session in the browser using the login function. It returns an error message "login_required".
Can anyone suggest how to proceed further in creating a session and setting cookies of keycloak using the keycloak-js adapter?