# Adding audience to token

**URL:** <https://community.auth0.com/t/adding-audience-to-token/84805>\
**Category:** Get Help\
**Tags:** jwt, management-api, auth0\
**Created:** [June 8, 2022, 11:58am UTC](https://community.auth0.com/t/adding-audience-to-token/84805 "2022-06-08T11:58:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![psr11140](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/psr11140/32/36486_2.png) [@psr11140](https://community.auth0.com/u/psr11140)\
**Post date:** [June 8, 2022, 11:58am UTC](https://community.auth0.com/t/adding-audience-to-token/84805/1 "2022-06-08T11:58:05Z")

</div>

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](https://dev-dlblb59r.us.auth0.com/user/info) and so i dont have the necessarry audience ([https://dev-dlblb59r.us.auth0.com/api/v2/](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](https://global.discourse-cdn.com/auth0/original/3X/0/4/042499b0e7012aaa8dbe3e08e44716c787dd3de8.png)  
the audience i have

![Capture d’écran 2022-06-08 135620](https://global.discourse-cdn.com/auth0/original/3X/f/9/f93fde782865f5655acd77616cd8d301bf89dfc9.png)  
the one required by management api

---

<div class="post-metadata">

**Author:** ![kahina](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kahina/32/33596_2.png) [@kahina](https://community.auth0.com/u/kahina)\
**Post date:** [June 8, 2022, 12:16pm UTC](https://community.auth0.com/t/adding-audience-to-token/84805/2 "2022-06-08T12:16:54Z")

</div>

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:

```auto
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)

```

---

<div class="post-metadata">

**Author:** ![psr11140](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/psr11140/32/36486_2.png) [@psr11140](https://community.auth0.com/u/psr11140)\
**Post date:** [June 8, 2022, 12:58pm UTC](https://community.auth0.com/t/adding-audience-to-token/84805/3 "2022-06-08T12:58:25Z")

</div>

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

 ![image](https://global.discourse-cdn.com/auth0/original/3X/8/e/8e5d342fcf496ef6734c313773052238b3a2770d.png)  
Thats the application i created in the dashboard with the same name of my app in my code

 ![image](https://global.discourse-cdn.com/auth0/original/3X/a/d/adae6630568fd3405afbaa2349bbcca11c53fc42.png)  
then we have my api with the identifier which will be the audience in my access token

In my code :

 ![image](https://global.discourse-cdn.com/auth0/original/3X/b/c/bca81b168900b44758f324d71ab6ad106a587f4f.png)  
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

 ![image](https://global.discourse-cdn.com/auth0/original/3X/0/5/054b614cfbd58b8eb1bf7269bbb43d731624e412.png)

 ![image](https://global.discourse-cdn.com/auth0/original/3X/f/5/f5354af37ec42e92b1d935035725342c868f3911.png)

my api auth0 configuration is simple

 ![image](https://global.discourse-cdn.com/auth0/original/3X/8/8/88bf266a90894460ae97abf847c2225744b44e13.png)

in my mvc app appsetting i have

 ![image](https://global.discourse-cdn.com/auth0/original/3X/8/2/8263c9abbd8250565780cffed4732b510dac001e.png)

in my api appsettings i have  
 ![image](https://global.discourse-cdn.com/auth0/original/3X/2/7/2702d5ae0d769631c213c7faaeb315cd20c073af.png)

so what i tried so far is adding the audience necessary (which is [https://dev-dlblb59r.us.auth0.com/api/v2/](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](https://global.discourse-cdn.com/auth0/original/3X/0/4/042499b0e7012aaa8dbe3e08e44716c787dd3de8.png)

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

---

<div class="post-metadata">

**Author:** ![just19k](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@just19k](https://community.auth0.com/u/just19k)\
**Post date:** [May 25, 2024, 6:58pm UTC](https://community.auth0.com/t/adding-audience-to-token/84805/4 "2024-05-25T18:58:33Z")

</div>

Did you ever figure this out?

I’m trying to figure out how to add additional audiences as well.

---

<div class="post-metadata">

**Author:** ![nik.baleca](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nik.baleca/32/68749_2.png) [@nik.baleca](https://community.auth0.com/u/nik.baleca)\
**Post date:** [January 29, 2025, 10:53pm UTC](https://community.auth0.com/t/adding-audience-to-token/84805/6 "2025-01-29T22:53:45Z")

</div>

Hi @psr11140

I am sorry about the late reply to your inquiry.

Since you want to make calls to the Management API using your own API, you can refer to this [community post](https://community.auth0.com/t/how-to-call-the-management-api-from-an-api/30174) which had a similar issue. Make sure to enable the **Client Credentials** grant so that you will be able to receive an access token from the management api to make the requests you are looking for.

From what I notice in the screenshots, you do not appear to be using a custom domain, however if you are looking into doing so, you can refer to this [community post](https://community.auth0.com/t/401-unauthorized-when-calling-our-api-if-the-front-end-is-using-auth0-custom-domain/91281) regarding the matter.

Related to your question regarding adding extra audience to a token, unfortunately, Auth0 does not support the feature at this time. You can look into alternative approaches regarding this approach. You can always post on our [Feedback](https://community.auth0.com/c/feedback/95) page regarding implementing this feature.

If you have any extra questions or already solved this issue, feel free to leave a reply or post again on the community page to let us know!

Kind Regards,  
Nik

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [February 12, 2025, 10:54pm UTC](https://community.auth0.com/t/adding-audience-to-token/84805/7 "2025-02-12T22:54:44Z")

</div>

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