auth0-samples / auth0-angular-samples

Auth0 Integration Samples for Angular 2+ Applications
https://auth0.com/docs/quickstart/spa/angular2
MIT License
283 stars 457 forks source link

Need to log in every time I refresh browser/page #191

Closed AlexDunca closed 4 years ago

AlexDunca commented 4 years ago

Hello,

I have downloaded the Angular Quick Start - 01 Login.

https://auth0.com/docs/quickstart/spa/angular2/01-login

Everything works fine, but if I refresh the page or access it again, I have to log in again. I spent few hours reading lots of posts regarding my issue, but with no luck.

Mac OS X 10.15.0 Browsers (tried also incognito - same behaviour) Chrome Version 80.0.3987.163 (Official Build) (64-bit) Safari Version 13.0.2 (15608.2.30.1.1)

I deployed the sample app on nginx on a server and the behaviour is the same.

Also, in the Auth0 logs, I can see lots of “Failed Silent Auth” with the error message: Login required.

Any ideas what am I doing wrong?

Thanks, Alex

aaronjonesii commented 4 years ago

^

stevehobbsdev commented 4 years ago

@AlexDunca The sample itself works ok for me in this regard, I'm guessing this is environmental.

This is a classic symptom of having third-party cookies being blocked. I would expect this error to surface in Safari as it blocks these cookies by default thanks to ITP, but you're saying you've tried it in Chrome with Incognito Mode? Have you got any extensions loading in Incognito Mode that blocks third-party cookies?

AlexDunca commented 4 years ago

Hi @stevehobbsdev , thanks for your reply. I have tried on a different machine (windows) and it works only on Firefox. In Chrome still having the same issue (incognito also).

Anyways, the problem is clear, the solution for this is not clear. Can you confirm that going for Auth0 custom domains can fix the issue?

stevehobbsdev commented 4 years ago

If the problem is indeed that the third-party cookies are being blocked somehow, then custom domains should solve your issue if your app and authorization server are on the same domain. It's the cross-origin part that is causing the problem.

AlexDunca commented 4 years ago

I will give a try with custom domains.

Thanks for help!