Auth0 React SDK loginWithRedirect() function not making token request upon successful login
Sep 10, 2025
Overview
The initial login the customer clicks calls the function 'loginWithRedirect'. The 'Auth0Provider' is configured to store the access token in localstorage, but upon successful login and redirect back to the app, the access token doesn't get stored in localstorage. In this scenario, the app redirects back to the login page. If initial login is called a second time (sometimes it actually needs to be clicked three or four times), the access token finally does get stored locally.
Solution
1. We were using `www.` in the original app URL, which Auth0 apparently doesn't support for our use case.
2. Our app formats the Auth0 localstorage token into several new pieces of localstorage data. We were relying on _those_ to determine authentication instead of relying on the Auth0 SDK directly. We were doing so in such a way that _our_ localstorage data was never available when we checked it, and so our authentication check failed and resulted in a redirect on our app's side, which is likely what was interrupting Auth0 as it was trying to establish the token/session.
After moving away from `www.`, and also relying on the Auth0 SDK directly instead of our own localstorage data, the issue is resolved.