My Angular app is losing it's auth state when I refresh the page

I am following all the instructions from this getting start guide: Auth0 Angular SDK Quickstarts: Login

But when I refresh my Angular 7 app, the auth state is lost. And I am receiving the following error messages. How can I keep the auth state when refreshing the page?

localHostAlert

js-error

Hey there @leongrin, as you stated when you refresh your app the state is lost but it’d odd that it doesn’t then feed off of your token at that point. To drill down deeper into this can we get a HAR file of your authentication workflow to make sure everything is copasetic there? When you record the har file of the login, be sure to select “Preserve log” to catch redirects and scrub the file of user passwords before passing it over to me in a direct message, thanks!

I wanted to follow up @leongrin and let you know that I sent you a response to your initial DM. When you get a chance can take a peek at that? Thanks in advance!

Hi,
I’ve got the same error with a React SPA hosted statically on AWS S3. I would like to get some help troubleshooting and could send the HAR via DM, if that helps.
Kind regards
Alexander

Nevermind, I found the solution. The website needs to be entered into the “Allowed Web Origins” list in the application’s settings. After doing that the reauthentication worked.

1 Like

I’m glad to hear that it all came together! Please let us know in the future if you have any additional questions we can assist with, thanks!

The auth is being lost only if you login using Facebook and then refresh the page.

For all other authentications, if you add the website to “Allowed Web Origins”, it will work.

I wanted to touch base @leongrin, after further investigating the HAR file you sent over we found in the callback after the successful authentication to Facebook, your request URL seems to be pointed back at login.auth0.com which may be giving you the trouble that you have been experiencing. If we could get this updated to point to your corresponding tenant, this should alleviate the issue you are faced with. Please let me know if you have any questions, thanks!

Request URL: https://login.auth0.com/login/callback?

Hi James,
As you probably know, I am using the Universal login.
I didn’t understand the fix you are proposing. I couldn’t find the login.auth0.com URL anywhere in my code. Could you please give me more specific instructions on what I should do?

Given this happens only for Facebook and Facebook is leading to a redirect to login.auth0.com this means you’re using developer keys for the Facebook connection (Test Social Connections with Auth0 Developer Keys).

The resolution would be to configure the connection with your own Facebook client information.

1 Like

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