How to get APP_METADATA from user while using @auth0/nextjs-auth0

Ready to post? :mag: First, try searching for your answer.
i’m trying to get the APP_METADATA from a logged-in user.

i know it’s not in the @auth0/nextjs-auth0 so from what i have read the safest way is to use the “Management API”.

my first API call to get a valid token from the “Management API” work well but when i try to get userinfo with the token. i receive “Request failed with status code 400”

let token = {};
var axios = require(“axios”).default;
var options = {
method: “POST”,
url: “https://TENANT/oauth/token”,
headers: { “content-type”: “application/x-www-form-urlencoded” },
data: new URLSearchParams({
grant_type: “client_credentials”,
client_id: “CLIENTID”,
client_secret: “CLIENTSECRET”,
audience: “https://TENANT/api/v2/”,
}),
};
await axios
.request(options)
.then(function (response) {
console.log(response.data);
token = response.data.access_token;
})
.catch(function (err) {
console.error(error);
});

options = {
method: “GET”,
url: “https://TENANT/api/v2/users”,
headers: {
“content-type”: “application/json”,
Authorization: “Bearer ${token}”,
},
};

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

did some of you have exemple of code i could try ?

Thanks

for those who as the same problem. you need to configure the permissions.

Go to Auth0 Management API → Machine to Machine Applications → expend your API and grant permiossions