401 when get userinfo by access_token in Angular 10

Hi everyone,

I am basing on the example https://github.com/okta/samples-js-angular/blob/master/custom-login/src/app/messages/messages.component.ts to get the access_token.
After I have it, I try to use the Postman with information

  • Url: https://dev-96157*.okta.com/oauth2/v1/userinfo**
  • Header: Authorization : Bearer <access_token>
    But the result is 401 in the response. Have any body have the sample issue ?

Thank you every much.

I have the same issue in React, see if you can take the Access Token and use postman. When I use post man and or replay the request while removing origin and referrer it works.

If you check the payload of your access token, can you confirm that it has been issued by the same authorization server you are sending it to? If the iss you see in your token doesn’t say https://dev-1234567.okta.com, can you try updating the request URL for your Userinfo call to point to the same issuer as the one that minted the token?

For example, if the iss value you see in the Access Token says https://dev-1234567.okta.com/oauth2/default, send it to https://dev-1234567.okta.com/oauth2/default/v1/userinfo

I get 401’s in Postman as well… there’s a problem with the token but it’s impossible to tell what that problem is. I suspect scope, but having tried several variations with no success, can’t say for sure.

Thanks andreaskouras.
After check authorization server, I saw the problem.
I issued with https://dev-1234567.okta.com/oauth2/default/v1/authorize
But I used the postman with link: https://dev-1234567.okta.com/oauth2/v1/userinfo (without default path).
So I received 401 in my case.

Thank you everyone.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.