Hi!
We are piloting with Auth0 to see if it would be a good fit for our application. However, when walking through the quickstart of Angular, we face some issues. We did the usual SO/Google research but none give a definitive answer to fix the issue. There is a range of topics touching upon the issue(s) described, but none give a definitive answer on how to actually fix it.
Our setup
We have the following setup to test with:
- A vanilla Auth0 tenant in EU with a Free license;
- One SPA registration for the Angular application. This is configured with all defaults as stated in the quickstart;
- One API application for a backend application to test some backend requests. Also same as in the quickstart is explained;
- Testing with browsers: Chrome Version 91.0.4472.106 (Official Build) (x86_64) and Firefox 89.0 (64-bit) on Mac;
- A demo application that can be found here: GitHub - maxhov/auth0
The issue
Logging in and retrieving user data works as expected. However, when trying to make a backend call that requires a new token to be retrieved (e.g. with a different audience), the application freezes. Upon debugging we found out that the this.authService.getAccessTokenSilently(options) call in the AuthHttpInterceptor is giving back an “Error: Login required”. This causes the entire authentication context (so to say) to be dropped and the user is required to relogin. The token is never attached to the request.
Steps that we tried (in any combination) without success:
- Enable refresh tokens
- Enable SSL
- Set cacheLocation to
localstorage - Relax browser settings as far as possible (Chrome recently dropped some SameSite flags unfortunately…)
Expected behaviour
As advertised, when calling an api that is configured in the HttpInterceptor.AllowedList an access token should be retrieved and added to the request.
Potential cause
Chrome making mention of SameSite cookie configuration for the following cookies: did_compact, auth0_compact when making requests to the /authorize endpoint. The actual issue texts are:
- Indicate whether a cookie is intended to be set in a cross-site context by specifying its SameSite attribute
- Indicate whether to send a cookie in a cross-site request by specifying its SameSite attribute
It seems that the cookies coming from Auth0 are not configured with SameSite=none?