401 Error to authorize user

I am using Single Sign On with openID, I integrate the okta with my application, everything is done.
Now I need to authorize the user,

I am getting the access token with the end point of :
https://{url}/oauth2/default/v1/authorize?

with this url its provide me the code which I convert the code to the access token and successfully done it.
NOW I need the user info with this token so I am using the url : {{url}}/oauth2/v1/userinfo
after I add my bearer access token in authorization to make request it gives me 401 error.

What mistake I am doing?

You seem to be mismatching the authorization server that issued the token, the “Default” Custom Authorization Server, with the one that you are sending the token to to get Userinfo data, as the URL you are using is for the separate Org Authorization Server. More details about the different server types found here.

Can you try sending the token instead to {{url}}/oauth2/default/v1/userinfo?

Thanks for the response, I tried the default server for authorization, but now i got 404

After 200 of getuserinfo api from access token, i receive the sub : “somekey”, where shoul I use this to get user information?

If you only see the “sub” claim returned from the /userinfo call, you likely only requested the “openid” scope when the token was requested.

If you are looking to get details about the user from the call, you will want to also request the “profile” scope, and potentially other base scopes for additional information. More details about the scope-dependent claims found here

I get the token from openid Scope, but I need the user information from that token, What can I do?

It still sounds like you should look to request the ‘profile’ scope to get more details about the user within the token itself.

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