# Bad audience when calling Management API using Machine-to-Machine App

**URL:** <https://community.auth0.com/t/bad-audience-when-calling-management-api-using-machine-to-machine-app/81478>\
**Category:** Get Help\
**Tags:** access-token, management-api\
**Created:** [April 8, 2022, 8:40pm UTC](https://community.auth0.com/t/bad-audience-when-calling-management-api-using-machine-to-machine-app/81478 "2022-04-08T20:40:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![briannl](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/briannl/32/34795_2.png) [@briannl](https://community.auth0.com/u/briannl)\
**Post date:** [April 8, 2022, 8:40pm UTC](https://community.auth0.com/t/bad-audience-when-calling-management-api-using-machine-to-machine-app/81478/1 "2022-04-08T20:40:49Z")

</div>

I see some other discussions about Bad audience. But no luck to fix the problem when I use M2M app.  
My Steps to reproduce the issue:

1. create `Machine to Machine Applications` and name it `m2m-app`

2. select the `Auth0 Management API` as the API to authorize to this M2M app.

3. select all the permissions under the API and save.

4. Now, we have the app. I tried the curl command captured right from the “Quick Start” tab of this app.

5. I send command to get an access\_token

```auto
	curl --request POST \
	  --url https://<my-pretty-domain-name>.us.auth0.com/oauth/token \
	  --header 'content-type: application/json' \
	  --data '{"client_id":"ABCDEFGHIJK123abcdefghijk","client_secret":"XYZXYZXYZXYZ123123123abcabcabc","audience":"https://<my-pretty-domain-name>.us.auth0.com/api/v2/","grant_type":"client_credentials"}'

```

1. I got back an access\_token like below:

```auto
	{
	   "access_token":"abcdabcdabcdabcd.ABCDABCDABCD.ABCD1234ABCD1234",
	   "scope":"...... read:users update:users delete:users create:users ......",
	   "expires_in":86400,
	   "token_type":"Bearer"
	}

```

1. I call the get user API

```auto
	curl --request GET \
	  --url https://login.auth0.com/api/v2/users/12345678 \
	  --header 'authorization: Bearer abcdabcdabcdabcd.ABCDABCDABCD.ABCD1234ABCD1234'

```

1. I got the response:

```auto
	{"statusCode":401,"error":"Unauthorized","message":"Bad audience: https://<my-pretty-domain-name>.us.auth0.com/api/v2/"}

```

I think I followed all the disccusions and seems the problem is not going away.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [April 11, 2022, 11:20pm UTC](https://community.auth0.com/t/bad-audience-when-calling-management-api-using-machine-to-machine-app/81478/3 "2022-04-11T23:20:34Z")

</div>

Hi @briannl,

Make sure you are using your _original auth0 domain_ when calling the management API, not your custom domain.

Explained in detail here: [Troubleshoot Custom Domains](https://auth0.com/docs/troubleshoot/integration-extensibility-issues/troubleshoot-custom-domains#-service-not-found-).

---

<div class="post-metadata">

**Author:** ![briannl](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/briannl/32/34795_2.png) [@briannl](https://community.auth0.com/u/briannl)\
**Post date:** [April 13, 2022, 2:24am UTC](https://community.auth0.com/t/bad-audience-when-calling-management-api-using-machine-to-machine-app/81478/4 "2022-04-13T02:24:47Z")

</div>

I guess the online document should be updated. It generate a curl with `https://login.auth0.com/api/v2/users/***` URL. It should mention that the word `login` should be the tenant’s domain name

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [April 13, 2022, 6:24pm UTC](https://community.auth0.com/t/bad-audience-when-calling-management-api-using-machine-to-machine-app/81478/5 "2022-04-13T18:24:17Z")

</div>

I’d be happy to submit that feedback. Can you share a screenshot and URI of which document you are referring to?

---

<div class="post-metadata">

**Author:** ![briannl](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/briannl/32/34795_2.png) [@briannl](https://community.auth0.com/u/briannl)\
**Post date:** [April 22, 2022, 12:02am UTC](https://community.auth0.com/t/bad-audience-when-calling-management-api-using-machine-to-machine-app/81478/6 "2022-04-22T00:02:56Z")

</div>

Hi Dan,  
I find out that if I logged in, the example is generated correctly with my domain. So, we are clear. Thanks a lot.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [May 25, 2022, 9:35pm UTC](https://community.auth0.com/t/bad-audience-when-calling-management-api-using-machine-to-machine-app/81478/7 "2022-05-25T21:35:00Z")

</div>


