# /userinfo API returns 401 Unauthorized

**URL:** <https://community.auth0.com/t/userinfo-api-returns-401-unauthorized/105157>\
**Category:** JWT.io\
**Tags:** api, auth0\
**Created:** [April 20, 2023, 2:01pm UTC](https://community.auth0.com/t/userinfo-api-returns-401-unauthorized/105157 "2023-04-20T14:01:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ilanoh](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@Ilanoh](https://community.auth0.com/u/Ilanoh)\
**Post date:** [April 20, 2023, 2:01pm UTC](https://community.auth0.com/t/userinfo-api-returns-401-unauthorized/105157/1 "2023-04-20T14:01:31Z")

</div>

I’m trying to retrieve user’s profile based on the Auth0 Access Token obtained during login.

I use the endpoint GET /userinfo

I successfully retrieve the Access Token using this function

```auto
const getUserMetadata = async () => {
        //const domain = "domain.us.auth0.com"
        const accessToken = await getAccessTokenSilently({
            authorizationParams: {
              audience: 'https://domain.us.auth0.com/userinfo', // Value in Identifier field for the API being called.
              scope: 'openid', // Scope that exists for the API being called. You can create these through the Auth0 Management API or through the Auth0 Dashboard in the Permissions view of your API.
            }
          });
        const tokenId = await getIdTokenClaims()
        const response = {
            access: accessToken,
            id: tokenId
        }
        return response
    }

```

I then make a get request to the API

```auto
get https://domain.us.auth0.com/userinfo
Authorization: "Bearer token"

```

I receive 401 Unauthorized

The token is created upon login with the default ‘Auth0 Management API’

It doesn’t work either when i use for audience

```auto
.us.auth0.com/api/v2/

```

or when I use for scope

```auto
read:openid

```

No solutions found anywhere on the internet, and in the documentation.  
How what should I do to make it works ?

Thank you

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [April 20, 2023, 10:26pm UTC](https://community.auth0.com/t/userinfo-api-returns-401-unauthorized/105157/3 "2023-04-20T22:26:59Z")

</div>

Hi there @Ilanoh welcome to the community!

> [@Ilanoh](#):
>
> The token is created upon login with the default ‘Auth0 Management API’

What exactly do you mean by this?

> [@Ilanoh](#):
>
> No solutions found anywhere on the internet, and in the documentation.  
> How what should I do to make it works ?

Do you mind sharing an example of an access token you’re attempting to use against `/userinfo`? Please redact any sensitive information.

Thanks!

---

<div class="post-metadata">

**Author:** ![Ilanoh](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@Ilanoh](https://community.auth0.com/u/Ilanoh)\
**Post date:** [April 23, 2023, 9:11am UTC](https://community.auth0.com/t/userinfo-api-returns-401-unauthorized/105157/4 "2023-04-23T09:11:22Z")

</div>

This is the API for login

 ![Screenshot 2023-04-23 at 12.06.52](https://global.discourse-cdn.com/auth0/original/3X/5/9/5949b05b69320df86a77a32f063f1cfca177ee30.png)

The access token is a jwt that I receive from getAccessTokenSilently, I place it in the get request Authorization header, but it doesn’t work.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [April 25, 2023, 12:20am UTC](https://community.auth0.com/t/userinfo-api-returns-401-unauthorized/105157/5 "2023-04-25T00:20:21Z")

</div>

Thanks for getting back to me!

Do you mind decoding an example access token at [jwt.io](http://jwt.io) and sharing a screenshot here? Please redact any information that you don’t want share.

Thanks!

---

<div class="post-metadata">

**Author:** ![Ilanoh](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@Ilanoh](https://community.auth0.com/u/Ilanoh)\
**Post date:** [April 25, 2023, 9:10am UTC](https://community.auth0.com/t/userinfo-api-returns-401-unauthorized/105157/6 "2023-04-25T09:10:05Z")

</div>

yes sure please find the screenshot here

 ![Screenshot 2023-04-25 at 12.06.00](https://global.discourse-cdn.com/auth0/original/3X/a/3/a39eff568592e42bb33db32783a1ccc004ba5788.png)  
 ![Screenshot 2023-04-25 at 12.06.17](https://global.discourse-cdn.com/auth0/original/3X/b/e/bee8d2eb1688aa3e7011ffe6af3255d93e93273d.png)

What do you think is the issue?

Thanks

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [May 12, 2023, 12:06am UTC](https://community.auth0.com/t/userinfo-api-returns-401-unauthorized/105157/7 "2023-05-12T00:06:18Z")

</div>

Hi there, sorry for the delayed response here - Were you ever able to get this sorted?

The access token you shared looks good to me , assuming its not expired. If you get a new access token and use the shell script [here](https://auth0.com/docs/api/authentication?#user-profile) to hit `/userinfo`, do you still get a `401`?

Let us know either way!

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [May 27, 2023, 12:07am UTC](https://community.auth0.com/t/userinfo-api-returns-401-unauthorized/105157/8 "2023-05-27T00:07:01Z")

</div>

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