Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"No state in response" error with OIDC_CLIENT and angularJS

I am trying to replace the old oidc-token-manager with oidc-client in my angular app, but I keep getting this error "No state in response", I have look at brockallen sample to learn how to use it, but not luck so far. Here is what I have in my service.

var config = {
                client_id: "myClient"
                , redirect_uri: "http://127.0.0.1:51899/callback.html"
                , response_type: "id_token token"
                , scope: "openid profile test"
                , authority: "https://localhost:44369"
            };
            var mgr = new Oidc.UserManager(config);

and similar thing on my callback page.

This is what I have in my mainController

var tokenManager = {
            mgr: {}
        };
        tokenManager.mgr = oidc.tokenManager();
        startSigninMainWindow(tokenManager);

        function startSigninMainWindow(tokenManager) {
            tokenManager.mgr.signinRedirectCallback().then(function (user) {
                var data = user.state.some;
            }, function (err) {
                console.log(err); // err:'No state in response'
            });
        }

Could any body tell me what I am doing wrong? Thanks. PS: BTW, I don't even get to see the login screen in the Identity Server any more

like image 759
Peter Avatar asked Aug 21 '16 23:08

Peter


People also ask

How do you fix no matching state in storage?

Clearing my browser cache (From Settings) fixed the issue for me. In some cases, I had to manually go into the Application tab and once you are at the homepage of your site, clear the session and state storage. That fixed the issue for me.

What is signinRedirectCallback?

signinRedirectCallback(url?: string): Promise<User> Returns promise to process response from the authorization endpoint. The result of the promise is the authenticated User .


1 Answers

In my case, there was garbage in the Local Storage. Open the chrome debugger "Application" tab and clear all the Local and Session storage. Then reload the app.

NOTE: as a developer you need to know that oidc-client uses session/local storage for a cache. It does not refresh the cache if, for example, you change the configuration of your token. You must manually clear the storage.

like image 78
John Henckel Avatar answered Nov 12 '22 00:11

John Henckel