Adding audience to token

Hi, i am creating a code in which iam using auth0 for authentification (so i have my api and a regular application), and the thing is i want to use the management api in my api but the audience i have when a user connect is my api and the other is https://dev-dlblb59r.us.auth0.com/user/info and so i dont have the necessarry audience (https://dev-dlblb59r.us.auth0.com/api/v2/). which is why i get the “unauthorized” message from the managment api when i try to send a request.

so what i want to ask is can i add the necessary audience to my token(is it possible?) or should i go for another strategie.

Capture d’écran 2022-06-08 135626
the audience i have

Capture d’écran 2022-06-08 135620
the one required by management api

Hello,
I don’t know if I got you well, but you should generate a token before executing a request in the management API.
To be honest, I couldn’t understand your problem, if you can share with us the code you’re executing it’d be better

i.e: that’s what I did to update user’s metadata via management API (in my API) using Axios:

let options = {
            method: 'PATCH',
            url: `https://${AUTH0_DOMAIN}/api/v2/users/${id}`,
            headers: {authorization: `Bearer ${token}`, 'content-type': 'application/json'},
            data: {user_metadata: data}
          };

        const response = await axios.request(options)

Thanks for the reply, well i can show my code of course but its kinda heavy so i need to organise it

So I have an application mvc and an api


Thats the application i created in the dashboard with the same name of my app in my code


then we have my api with the identifier which will be the audience in my access token

In my code :


so thats the simple class where i am going to call the management api with the httpclient
the headers authorization is going to be implemented with bearer token gotten from httpcontext

In my mvc app thats how ii implemented my auth0 authentification configuration

my api auth0 configuration is simple

in my mvc app appsetting i have

in my api appsettings i have
image

so what i tried so far is adding the audience necessary (which is https://dev-dlblb59r.us.auth0.com/api/v2/) in the appsetting but then again i have trouble with my configuration because my options.Audience in programs(in my api) becomes null.
so i want to add the audience in my token.

now i have those audiences in my token

Capture d’écran 2022-06-08 135626

i hoped it helped , and thanks again for the reply.