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

Angular 6 authorization code flow - user_info endpoint

Open jchandramohan opened this issue 7 years ago • 3 comments

I am trying to implement authorization code flow from Angular 6 application hosted in IIS. Library versions -> "oidc-client": "^1.6.0", "babel-polyfill": "^6.23.0".

After IDP login is successful, token endpoint is called and I see http response 200. But it doesn't make user_info endpoint call. Token endpoint call was the last one and it stops there.

Console shows these errors:

  1. Access to XMLHttpRequest at 'https://exampleidp/oidc/token' from origin 'https://examplespa.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
  2. Access to XMLHttpRequest at 'https://myexampleidp.com/oidc/token' from origin 'https://mySPA.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
  3. signinRedirectCallback function call errors out with this error -> Error: Network Error.

This is my UserManagerSettings object: { authority: 'exampleidpurl', client_id: 'exampleclientid', client_secret: 'examplesecret', redirect_uri: 'examplespaurl', post_logout_redirect_uri: 'examplelogouturl', response_type: 'code', scope: 'openid', filterProtocolClaims: true, loadUserInfo: true, metadata: { issuer: 'exampleidpurl', authorization_endpoint: 'exampleauthurl', token_endpoint: 'exampletokenurl', userinfo_endpoint: 'exampleuserurl', end_session_endpoint: 'examplesessionurl', jwks_uri: 'examplejwksurl' }

Based on this reference https://www.chromium.org/Home/chromium-security/corb-for-developers , I thought item #2 can be ignored. I tried to fix item #1 by adding http response headers (access-control-allow-origin), still the result is same. I have tried adding events (addUserLoaded, etc) but they don't fire as it stops after receiving response from token endpoint.

Anyone faced this kind of issue? Any suggestions will be of much help. Thanks.

jchandramohan avatar Mar 01 '19 23:03 jchandramohan

Not sure why in your scenario there's no call to user info -- did you disable that setting in the callback page's options, perhaps?

brockallen avatar Apr 11 '19 16:04 brockallen

Any update?

brockallen avatar Apr 26 '19 14:04 brockallen

Hi @jchandramohan,

How did you solve this? I'm facing the same issue.

thanks

csharpq avatar Jun 20 '19 06:06 csharpq