I think this is an error related to angular 5.2.8 & 6 . With angular 5.2.7 work fine. I create a ng5 branch and update angular to latest 5.2.8 and the error com in! anybody can direct me to an angular 5.2.8 and later sample with oidc-client-js ?
Asked
Active
Viewed 1.5k times
13
-
Maybe show some code or give some more context – David Mar 11 '18 at 13:58
-
@David See the https://github.com/client-sdk-samples/sample-angular-OidcClient/tree/ng5 – Mike Anderson Mar 11 '18 at 16:19
-
I wonder if these are similar - https://github.com/damienbod/angular-auth-oidc-client/issues/195 – AlexB Mar 11 '18 at 17:22
-
Did you managed to figure this out? Experiencing the same issue. – penleychan Mar 12 '18 at 17:38
-
@21seconds my answer work fine to me , please mark it as accept if it work for you too. – Mike Anderson Mar 12 '18 at 19:02
2 Answers
8
It is caused by URI encoding of state in the window.location.hash. For me this fix the issue:
if (window.location.hash) {
window.location.hash = decodeURIComponent(window.location.hash);
// authorizedCallback returns wrong result when hash is URI encoded
this.oidcSecurityService.authorizedCallback();
} else {
this.oidcSecurityService.authorize();
}

Mike Anderson
- 738
- 1
- 8
- 23
-
Thanks, `window.location.hash = decodeURIComponent(window.location.hash);` This is the line I needed. – penleychan Mar 13 '18 at 14:20
6
If you are doing something custom like me and your issue has nothing to do with hash location, just ignore it:
completeAuthentication(): Promise<void> {
return this.manager.signinRedirectCallback().then(user => {
this.user = user;
}).catch((err) => {});
}

Post Impatica
- 14,999
- 9
- 67
- 78
-
1+1 for this, this is exactly what I initially did and this confirms it. I am using React with React-Router and for some reason the state is not read by the oidc-client. – ᴳᴿᴵᴹᴹ Feb 07 '20 at 15:11