auth0.js icon indicating copy to clipboard operation
auth0.js copied to clipboard

IE11 - Nonce does not match

Open critchie opened this issue 9 years ago • 6 comments

  • Code Snippet: 05-Token-Renewal from Samples
  • Auth0.js version: 8.8.0
  • Browser: IE11 v. 11.0.9600.18015IS
  • OS: Windows 7 Professional SP1

Description/Issue Followed the instruction in the README.md pointing the app to my API. The app works flawlessly using Chrome. IE11 however fails when the authService.handleAuthentication is called after being redirected back to the app after a successful login. From what I can determine it fails with "Nonce does not match".

critchie avatar Jul 18 '17 21:07 critchie

Did you change the sample code? If so, can you isolate the issue with a simple example so we can reproduce?

luisrudge avatar Jul 18 '17 21:07 luisrudge

The only thing I did was add some alerts to the handleAuthentication method:

  public handleAuthentication(): void {
    alert(window.location.href);
    this.auth0.parseHash((err, authResult) => {
      alert('Result: ' + JSON.stringify(authResult));
      alert('Error: '+ JSON.stringify(err));
      if (authResult && authResult.accessToken && authResult.idToken) {
        window.location.hash = '';
        this.setSession(authResult);
        this.router.navigate(['/home']);
      } else if (err) {
        this.router.navigate(['/home']);
      }
    });
  }

alert('Result: ' + JSON.stringify(authResult)); That displays Result: null

alert('Error: '+ JSON.stringify(err)); That displays Error: {"error":"invalid_token","errorDescription":"Nonce does not match."}

I also changed the silent.html to look like the one from Issue #429.

<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <script>
      parent.postMessage(window.location.hash, 'http://localhost:4200');
  </script>
</head>
<body></body>
</html>

Everything else is unchanged except for the variables pointing it to my API.

The app starts and I see the Home and Login buttons. I click the login button. This redirects me to my Auth0 login for my API. I successfully log in. All the callbacks and silent html appear to be hit. The app restarts due to the redirect from Auth0, the handleAuthentication gets hit from app.component and I get the alerts.

critchie avatar Jul 18 '17 21:07 critchie

I'm seeing the same issue with auth0.js v8.9.3 on Safari Private window. After authentication, I see {"error":"invalid_token","errorDescription":"Nonce does not match."}. I could reproduce it with current angularjs quickstart as-is https://auth0.com/docs/quickstart/spa/angularjs

ashishdasnurkar avatar Sep 05 '17 09:09 ashishdasnurkar

it seems the failover to CookieStorage isn't working. I added console.log for getItem and setItem. In Safari private window, auth0.js falls back on using CookieStorage correctly and uses it to set the Nonce in the cookieStorage. However after authentication when auth0.js does getItem the nonce is null. See the screenshot below

screen shot 2017-09-05 at 6 29 02 pm

ashishdasnurkar avatar Sep 05 '17 10:09 ashishdasnurkar

store.js seems to have solved similar issue for reference https://github.com/marcuswestin/store.js/issues/168#issuecomment-283123205

ashishdasnurkar avatar Sep 05 '17 11:09 ashishdasnurkar

Hi! I'm sorry about the copy/paste message, but I'm cleaning up some stale issues. 🗑 It's been a while since this issue was opened. Are you still having this issue with the latest version? If so, please reopen it with some repro steps so we can help!

luisrudge avatar Mar 19 '18 02:03 luisrudge