Search code examples
javascriptangularoidc-client-js

signinSilentCallback with oidc-client getting "user not found in storage"


I'm using oidc-client 1.3.0 with an angular 4 app. The initial authentication (signinRedirect) is working just fine. But, when the token expires it loads the silent-renew.js and attempts to do:

Oidc.UserManager().signinSilentCallback();

It gets an error (or some level of message) saying "User not found in storage". Therefore, the user is not getting updated with the new token info.

When I step into oidc-client I can see that it finishes up with a Promise.resolve(), where I would expect it would send the user.

From UserManager.js, the user here comes back as undefined:

signinSilentCallback(url) {
    Log.debug("UserManager.signinSilentCallback");
    return this._signinCallback(url, this._iframeNavigator).then(user => {
        if (user) {
            if (user.profile && user.profile.sub) {
                Log.info("signinSilentCallback successful, signed in sub: ", user.profile.sub);
            }
            else {
                Log.info("signinSilentCallback successful");
            }
        }

        return user;
    });

From IFrameNavigator.js where the Promise is resolved:

callback(url) {
    Log.debug("IFrameNavigator.callback");

    try {
        IFrameWindow.notifyParent(url);
        return Promise.resolve();
    }
    catch (e) {
        return Promise.reject(e);
    }
}

If you've gotten this to work in your angular4 app (or, I'm not picky, some other app), help me out :)


Solution

  • Looks like I was following a red herring with this message, "User not found in storage", as there really wasn't a problem there. The problem I was having was updating the authorization header to include the renewed token. Once I got that, everything was happy.