Auth0 isAuthenticated() returns false after successful login redirect

Viewed 207

I have a really simple Auth0 SPA integration, but isAuthenticated() always returns false even after a successful redirect after login. So I'm not getting any errors here, and I have added my URL in the app settings and checked that the ports match (http://localhost:8888/auth0.html).

const auth0 = await createAuth0Client({ domain, client_id });

const isAuthenticated = await auth0.isAuthenticated();

if (!isAuthenticated) {
  loginButton.addEventListener("click", () =>
    auth0.loginWithRedirect({ redirect_uri: window.location.href })
  );
} else {
  logoutButton.addEventListener("click", () =>
    auth0.logout({ returnTo: window.location.href })
  );
}
0 Answers
Related