How do you get only one users ID number in Auth0?

I am using auth0 for authentication and I am wanting to retrieve the user_id of the user that is currently signed in in order to retrieve that users data from my database.

Right now I am using the request URL:
https:// my tenant .us.auth0.com /api/v2/users?fields=user_id

in my code:
var axios = require(“axios”).default;
var options = {
method: ‘GET’,
url: ‘https:// my tenant .us.auth0.com /api/v2/users?fields=user_id’,
headers: {authorization: 'Bearer MY_MGMT_API_ACCESS_TOKEN '}
};

axios.request(options).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.error(error);
});
}

and in the console in my website it gives me a list of all user_ids in my auth0 account. I just want the one user_id from the user that is currently logged in. How do I do this?

Hi @jam10 ,

An easier way may be to instead use the ID token and/or the userinfo endpoint, provided you included at least the openid scope when you logged the user in. The user_id will be in the “sub” claim.

You either request an id token when you log the user in (response_type=token id_token for example) so it is returned to your callback URL, or call the userinfo endpoint with the user’s access token.