I implemented authentication with Auth0 in my application, but I cannot log in successfully. The provider configuration seems correct. Here is the link to my sandbox for reference: https://codesandbox.io/p/sandbox/bold-architecture-kswpvv
Auth0 Configuration:
- Allowed Callback URLs:
http://localhost:5173
, https://auth.domain.com/callback
- Allowed Logout URLs:
http://localhost:5173
, https://auth.domain.com
- Allowed Web Origins:
http://localhost:5173
, https://auth.domain.com
Issue Description:
When I try to log in using email and password:
-
I am redirected to the homepage as expected.
-
The resulting URL includes the authorization code
and state
:
http://localhost:5173/?code=GFEDIUBLIuygliugyky587juygikUFKUYFkuy54&state=KJGHFJYRD6%JUHYGFKYTfku1278JKYTFiuyf5dijktuFKHGf76cgfhCKyh5MGHfkfvk%3D%2D
-
Problem: The isAuthenticated
state remains false
, so the Login button continues to display because it is not authenticated.
Question:
Why does the isAuthenticated
state remain false
even after a successful login?
Note: I’m using the development URL (http://localhost:5173
) and would appreciate any guidance to resolve this issue. Thank you in advance!
Hi @abraham
Welcome to the Auth0 Community!
I have tried reproducing the issue on my end using your configuration provided in the sandbox, however my application appears to be running as intended. I have kept everything inside the files as provided and this is the result I received after logging in with a test user inside the application:
There might be some kind of misconfiguration on your end when you have integrated your application, otherwise, the isAuthenticated function appears to be returning True.
I would recommend to re-configure your application with Auth0 or attempt using the sample app and modify it to your liking. If you are facing any further difficulties with your implementation or have any extra questions, feel free to leave a reply!
Kind Regards,
Nik
Hi @Nik.Baleca !
Thanks for taking the time to answer, I am working with Vite and my code has the same structure as the sandbox, I understand that this should not affect. In the configuration of Auth0 I am working with a Regular Web Application, in a tenant in a Development environment and I have added a custom domain to customize the design of the login page, I understand that all the above configuration should not affect the login, right?
I was repeatedly checking the integration of my application, but the error continues, the code and state is applied in the url and isAuthenticated is set to false, is there any other configuration in Auth0 that I am forgetting?
Hi again @abraham
Thanks for the extra insight on your situation, I presumed that since you are using React as seen in your sample code that your application was a SPA not a Regular Web App.
Once I attempted to integrate the code on a regular we app application, I could replicate your issue and it appears that the main issue is caused by the fact that the token is unauthorized, that is why the isAuthorized function always returns false.
This issue can be solved by switching your application’s Authentication Method to None.
The reason why I believe that the authentication is unauthorized is due to the fact that since you are using a Regular Web App, when the user authenticates, they make a POST request and as per our documentation in our Authentication API, the request must include a client secret.
Since the React SDK that you tried to integrate your app with is actually build to be for a SPA application, it does not use or parse as a parameter the client secret.
I would recommend to continue either with the Authentication Method as None if you wish to continue with a Regular Web Application or if it is not a tedious approach, to attempt to integrate your app to a SPA application on your tenant and perhaps use our React SDK sample to build your app upon.
I hope this information was helpful and of course if you have any additional question, feel free to leave a reply on the post.
Kind Regards,
Nik
1 Like
Thank you very much @Nik.Baleca , that solves my problem. Thanks again!