Keycloak auth request returning 401 error even after successful login and redirect - React JS

193 Views Asked by At

After log in with credentials and being redirected back to my website, keycloak request returns 401.

Note! Im running keycloak locally using docker container

This is my code for handling auth within react-js:

` const [isLogin, setLogin] = useState(false);

useEffect(() => { const _kc = new Keycloak({ realm: "Manter", clientId: "manter", url: "http://localhost:4000/", });

_kc
  .init({
    onLoad: "login-required",
    checkLoginIframe: false,
  })
  .then((res) => setLogin(res));`

I have tried connecting to local host as well as 127.0.0.1:4000. I have tried enabling front-end url and also played around with auth settings within keycloak itself.

0

There are 0 best solutions below