isAuthenticated always returns false (React)

When I tried to integrate auth0 with my react app, it seems that isAuthenticated is always false, even when login is successful. Has anyone encountered the same issue?

I am using auth0-react version 1.3.0. Tested with Safari and Chrome.

I have tested:

  • calling loginWithRedirect() a second time will not yield the login/signup page again, also the number of Logins is updated from the User Management console (so I am assuming login is successful)
  • the sample app is working correctly
  • refresh page does not solve the problem
  • isLoading is not the problem (both isLoading and isAuthenticated are false after login
  • the Application Type is SPA

Welcome to the Auth0 Community, @tingwei758!

Could you check that the authentication API is returning to the correct callback URL without any issue, please?

In order for isAuthenticated to get set to true, the function in onRedirectCallback has to get called. If the redirectUri doesn’t load completely, the onRedirectCallback fn will not get called.

If the above is not the issue, my suggestion would be to try our React quickstart: when you create a new application within the Auth0 dashboard, you can try to download and run the Quickstart application example for React that is also available from the “Quickstart” tab on this page. If this works, then the issue would probably be on your code, so you could compare the code snippet of the callback handling code within the custom code written with the code that is in the quickstart sample, we may be able to identify what is different to cause the unexpected behavior.

2 Likes

Thank you so much, Ale! You are right. The problem is that my redirectURI is incorrect.

1 Like

Thanks for helping on this one @Ale !

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.