I created a access token with My custome API
{
“client_id”: “KtIK6BuIVodFkblvt3QD5yjsZNaMsLFH”,
“client_secret”: “”,
“audience”: “https://custom-domain/api/v2/”,
“grant_type”: “client_credentials”
}
AnD i got token With that token I call APIs
https://custom-domain/api/v2/organizations/org_WgaeQUZIWxzKGJjy
But it getting
{
“statusCode”: 401,
“error”: “Unauthorized”,
“message”: “Bad audience: https://custom-domain/api/v2/”
}
I already auhorized the API in M2M app KtIK6BuIVodFkblvt3QD5yjsZNaMsLFH.
Hi @muhammad.ali,
Welcome to the Auth0 Community!
The audience should be the identifier of said API, you’ll find it in your APIs settings.
If you have any other questions feel free to let us know.
Have a good one,
Vlad
1 Like
Thanks for the help!
So, I’m using the same identifier as the audience, but I’m running into a “bad audience” error.
My goal is to use custom APIs with limited permissions for our M2M apps, instead of the default Auth0 Management API. I’m using these custom APIs to get tokens (via the M2M app flow) and then using those tokens to access other management APIs. The “bad audience” error happens when I try to use the token to get organization details.
Basically, I want a separate custom API for each M2M app, and each M2M app would be authorized with its own organization using grant client access. This way, the tokens are only valid for that specific organization.
Any ideas why I’m getting the “bad audience” error and how to fix it? I’m starting to wonder if this approach with custom APIs will even work.
Thanks again!
I got a response on another ticket saying that custom APIs aren’t designed for this – they’re for authorizing machine-to-machine communication, not for making management API calls. Is that right?
Tganks again
Yes, that is right. The Management API has all of the possible permissions already active for modifying your Auth0 account. That includes managing users and setting up connections. Any other custom API is made for limited access to everything the Management API does, but they don’t call the Management API.
1 Like