IdentityModel / oidc-client-js

OpenID Connect (OIDC) and OAuth2 protocol support for browser-based JavaScript applications
Apache License 2.0
2.43k stars 842 forks source link

Unexpected token 'else' in oidc-client.min.js causing react app to refresh after Azure AD login #1273

Closed lciii closed 3 years ago

lciii commented 3 years ago

So I'm using oidc-client on a react app to have my users SSO to Azure AD. Everything works fine...

...except, about every X minutes or so the page will refresh with this in the console (X seems to be between 30 and 60 minutes).

enter image description here

Here's the error text in the image above:

BSSO Telemetry: 

{
  "result": "Reload",
  "error": null,
  "type": "ChromeSsoTelemetry",
  "data": {
    "extension.id": "ppnbnpeolgkicgegkbkbjmhlideopiji"
  },
  "traces": [
    "BrowserSSO Initialized",
    "Creating ChromeBrowserCore provider",
    "Sending message for method CreateProviderAsync",
    "Received message for method CreateProviderAsync",
    "Using Chrome extension with id ppnbnpeolgkicgegkbkbjmhlideopiji",
    "Pulling SSO cookies",
    "Sending message for method GetCookies",
    "Received message for method Response",
    "SSO cookie detected. Refreshing page."
  ]
}

VM146 oidc-client.min.js:42 Uncaught SyntaxError: Unexpected token 'else'
VM147 silent-refresh.html:11 Uncaught ReferenceError: Oidc is not defined

Here's what I've got in my silent-refresh.html:

<head>
  <title></title>
</head>
<body>
  <script src="oidc-client.min.js"></script>
  <script>
    // debugger;
    let userManager = new Oidc.UserManager()
    try {
      userManager.signinSilentCallback()
    } catch (err) {
      console.log('silent sign in failed')
      console.log(err)
    }
  </script>
</body>

And I've just got a oidc-client.min.js file sitting next to it that I got from here.

What I've tried

This was originally posted on stack overflow here

brockallen commented 3 years ago

Not sure. Any updates?

jEnbuska commented 3 years ago

Don't know if this is useful information but, did you notice that you are not handling async error from promise returned from signinSilentCallback?

brockallen commented 3 years ago

Yea, perhaps that's the issue. Since we didn't hear back, I'll close.