IdentityModel / oidc-client-js

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

React app oidc-client IE11 problem when calling signInCallback() #1243

Closed soowwy closed 3 years ago

soowwy commented 4 years ago

Hey guys! So I asked this on stackoverflow first but nobody seems to notice or know the answer. I'm banging my head over this for a couple of days now and could really use some help:

So I'm using oidc-client and it works for every browser except IE11. I'm calling the function from a js bundle into a static html which is located in a public folder.

window.onload = function() { 
  signInCallback();
};

the code in the callbacks.js is:

const signInCallback = () => {
    new UserManager({ response_mode: "query" })
        .signinRedirectCallback()
        .then((user) => {
            if (user) {
                window.location = user.state.redirectUrl;
            } else {
                GetBaseUrl().then((url) => { window.location = url; });
            }
        }).catch((e) => {
            console.error(e);
        });
};

And this is the error i get in IE11: 1

The first issue I tried solving is window.onload which doesn't seem to work in IE. So I changed the code in the html file to this (I added the CDN for the oidc-client in the html) and again it was working fine with the other browsers:

new Oidc.UserManager({ response_mode: "query" })
    .signinRedirectCallback()
    .then(function(user) {
        if (user) {
            window.location = user.state.redirectUrl;
        } else {
            GetBaseUrl().then(function(url) { window.location = url; });
        }
    }).catch(function(e) {
        console.error(e);
    });

But of course, the IE11 says different: 2

I tried a couple of more things, like setting a setTimeout and adding polyfills, added "new" in front of the window.onload function.

brockallen commented 3 years ago

Any update on this?