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.
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:
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
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
i hoped it helped , and thanks again for the reply.
Since you want to make calls to the Management API using your own API, you can refer to this community post 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 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 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!