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
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
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
.us.auth0.com/api/v2/
or when I use for scope
read:openid
No solutions found anywhere on the internet, and in the documentation.
How what should I do to make it works ?
Thank you