Auth0 React SDK loginWithRedirect() function not making token request upon successful login

Problem statement

The Auth0 React SDK’s loginWithRedirect function fails to store the access token locally within the app upon successful login.

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 the initial login is called a second time (sometimes it actually needs to be clicked three or four times), the access token finally get stored locally.


It turns out there were two problems all along:

  1. in the original app URL, www. is used, but Auth0 doesn’t support this, so it needs to be removed.
  2. use Auth0 SDK directly instead of localstorage data.