I’m trying to integrate Keycloak into an application with existing login. If Keycloak login is successful, it should create a new user if one doesn’t already exist but there are a couple problems. How do I get the username to check against the database on my server? In the code below it doesn’t look like the callback is resolving and therefore can’t see user info:
keycloakLogin = async () => {
try {
const keycloak = Keycloak("keycloak.json");
keycloak
.init({
onLoad: "login-required",
})
.then((authenticated) => {
if (authenticated) {
//call api to either login or register and log in the user
console.log("user info");
console.log(keycloak.userInfo);
}
});
} catch (error) {
throw error;
}
};
The user is directed to the Keycloak login page but nothing happens when they log in and return except the URL has some session params which I don’t think will be useful for me in this case.