oidc-client-js icon indicating copy to clipboard operation
oidc-client-js copied to clipboard

No matching state found in storage

Open raigol opened this issue 9 years ago • 4 comments

Angular2 and IdentityServer4 I get: No matching state found in storage.

the same code works perfectly in development when running from Angular 2 cli ng serve localhost:4200

but when I do ng build --prod

and deploy to server I start getting "No matching state found in storage". I have checked that alls URLs are correct (authority, redirect_uri, post_logout_redirect_uri). What might cause this error?

the callback page is auth.html same code from https://github.com/jmurphzyo/Angular2OidcClient/blob/master/src/auth.html

auth.service has exact code from https://github.com/jmurphzyo/Angular2OidcClient/blob/master/src/app/shared/services/auth.service.ts

the Log from Chrome Developer Console

UserManager.getUser oidc-client.js:8265 _loadUser oidc-client.js:8265 WebStorageStateStore.get user:undefined:undefined oidc-client.js:8265 UserManager.signinRedirectCallback oidc-client.js:8265 RedirectNavigator.url oidc-client.js:8265 _signinEnd oidc-client.js:8265 OidcClient.processSigninResponse oidc-client.js:8265 UrlUtility.parseUrlFragment oidc-client.js:8265 WebStorageStateStore.remove 94ab8104dbf541aa8169559f329c97d7 oidc-client.js:8265 no user storageString oidc-client.js:8285 No matching state found in storage error @ oidc-client.js:8285

raigol avatar Mar 06 '17 19:03 raigol

Not sure. If it works in dev, but not in prod, then sounds like an environmental issue?

brockallen avatar Mar 07 '17 18:03 brockallen

Also, make sure the URL you start from the is the same you're redirecting to (http vs https for example).

brockallen avatar Mar 07 '17 18:03 brockallen

thanks for the tip about URL. I managed to get it working!!!

as the problem happens on auth.html page I tested what happens if I replace it with callback.html from Quickstart samples.

and with the code from quickstart it works :)

this works new Oidc.UserManager().signinRedirectCallback().then(function () { window.location = "index.html"; })

this does not work new UserManager().signinRedirectCallback().then(function (user) { if (user == null) { document.getElementById("waiting").style.display = "none"; document.getElementById("error").innerText = "No sign-in request pending."; } else { window.location = "/"; } })

seems the difference comes from "index.html" vs "/".

raigol avatar Mar 07 '17 19:03 raigol

I got this error trying to mix this client (oidc-client.js) with the angular-auth-oidc-client package. I didn't realize I was mixing the two and this came about from hours and hours of googling trying to get authentication working. So I removed this callback page completely and went back to following the instructions on the angular-auth-oidc-client wiki.

PostImpatica avatar Nov 06 '18 15:11 PostImpatica