I’m working on an Angular project where we decided to use Auth0 for authentication. We implemented everything a while ago and all was good. I made the mistake of only testing the application in Chrome but then discover that using our application with Firefox doesn’t work.
You get the Auth0 login screen and you are able to login but then when it redirects to our application you can see that it tries to load our application but seems to be stuck continuously reloading the redirect URL. I used the example code provided by Auth0 and really didn’t add anything special. So I thought this would occur to a lot more people but in general I can’t really find anyone who had the same issue and found the answer on why its keeps on reloading the redirect URL in Firefox.
Does anyone have a clue what is going wrong in Firefox and how I can fix the issue?
has this been solved yet? I am using angular 9 and sometimes I am required to login more than once. The problem seems to be solved when I set initialNavigation: false in the routing module: imports:
[RouterModule.forRoot(routes, {initialNavigation: false})]
Hi all, I managed to solve this issue by setting the url with ?code at the beginning of handleAuthCallback function and pass the url in client.handleRedirectCallback(this.urlFromAuth0) and add some delay to isAuthenticated$
private urlFromAuth: string;
handleRedirectCallback$ = this.auth0Client$.pipe(
concatMap((client: Auth0Client) => from(client.handleRedirectCallback(this.urlFromAuth)))
);
isAuthenticated$ = this.auth0Client$.pipe(
delay(500), // add delay to pipe
switchMap((client: Auth0Client) => from(client.isAuthenticated())),
tap(res => this.loggedIn = res)
);
private handleAuthCallback() {
// Call when app reloads after user logs in with Auth0
this.urlFromAuth0 = window.location.href;
const params = window.location.search;
...
}
Dear @kphay-11
Thank you very much for sharing this.
I have been struggling with a different symptom (There are no query params available for parsing) for the last couple of days on Safari and Chrome, with no redirect loop.
Your solution fixed my issue (I don’t need the delay though). Thanks a lot!!!
@konrad.sopala Any idea why client.handleRedirectCallback(url) needs the url? Is there a timing/race condition? It used to failed sporadically for me with 1.8.2 until I moved to 1.10 and now I could no longer login at all (Angular 9.1)