# Issuer with custom domain in M2M token

**URL:** <https://community.auth0.com/t/issuer-with-custom-domain-in-m2m-token/66050>\
**Category:** Get Help\
**Created:** [July 13, 2021, 6:24am UTC](https://community.auth0.com/t/issuer-with-custom-domain-in-m2m-token/66050 "2021-07-13T06:24:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![smirauta](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/smirauta/32/15135_2.png) [@smirauta](https://community.auth0.com/u/smirauta)\
**Post date:** [July 13, 2021, 6:24am UTC](https://community.auth0.com/t/issuer-with-custom-domain-in-m2m-token/66050/1 "2021-07-13T06:24:23Z")

</div>

Hello Auth0 team,

We have M2M applications and our tenants are configured with custom domains. We read in the Auth0 documentation that, in order to generate access tokens having the issuer containing the custom domain, we must call the /token endpoint using the custom domain URL:

> **[Custom Domains](https://auth0.com/docs/customize/custom-domains)**
>
> Understand how a custom domain (CNAME or vanity URL) can help you unify your brand and show continuity to your users.

That’s what we do, but the M2M tokens still contain the auth0 default domain, the “iss” claim ends in “[auth0.com](http://auth0.com)”. These tokens go to customers and we need to have the custom domain instead. How to achieve that?

Thank you!

---

<div class="post-metadata">

**Author:** ![sidharth.chaudhary](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sidharth.chaudhary/32/20686_2.png) [@sidharth.chaudhary](https://community.auth0.com/u/sidharth.chaudhary)\
**Post date:** [July 14, 2021, 1:03am UTC](https://community.auth0.com/t/issuer-with-custom-domain-in-m2m-token/66050/2 "2021-07-14T01:03:16Z")

</div>

Hey @smirauta ,

I just tested with my custom domain and client\_credentials exchange grant, I was  
able to see `iss` as the custom domain in the Access Token

```auto
Example: 
URL : https://my_custom_domain/oauth/token
{"client_id":"my_client_id","client_secret":"my_client_secret","audience":"my_sudience","grant_type":"client_credentials"}

```

Can you DM me your command and payload to check?

Regards,  
Sid

---

<div class="post-metadata">

**Author:** ![smirauta](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/smirauta/32/15135_2.png) [@smirauta](https://community.auth0.com/u/smirauta)\
**Post date:** [July 14, 2021, 7:54am UTC](https://community.auth0.com/t/issuer-with-custom-domain-in-m2m-token/66050/3 "2021-07-14T07:54:52Z")

</div>

Thank you, Sidharth,

I rechecked. My application is an M2M application. We have an own API defined in Auth0 which is enabled for that M2M app. We enabled the “Token Endpoint Authentication Method Basic” on our M2M app, so that we call the token endpoint like that:

```auto
curl --request POST --url https://my_gateway/security/oauth/token --header 'content-type: application/json' --header 'Authorization: Basic NF...TQ==' --data '{"audience":"https://my_api.com","grant_type":"client_credentials"}'

```

I have identified the cause: the problem is that we have put the Auth0 /token endpoint behind a gateway. The gateway forwards the request to the Auth0 /token endpoint with the custom domain. But the issuer in the token contains the Auth0 default domain “[https://tenant.auth0.com/](https://tenant.auth0.com/)”. If I call the /token endpoint directly with the custom domain (without going through the gateway), it works, the issuer is then “https://my\_custom\_domain.com”.

But still the question remains: do you have an idea how to solve that? Since the gateway forwards to Auth0 using the custom domain, I don’t understand why Auth0 doesn’t recognize it in this case.

---

<div class="post-metadata">

**Author:** ![sidharth.chaudhary](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sidharth.chaudhary/32/20686_2.png) [@sidharth.chaudhary](https://community.auth0.com/u/sidharth.chaudhary)\
**Post date:** [July 15, 2021, 5:14am UTC](https://community.auth0.com/t/issuer-with-custom-domain-in-m2m-token/66050/4 "2021-07-15T05:14:07Z")

</div>

Hey @smirauta Calling Auth0 with custom domain will lead to token being issued with `iss` as custom domain as well. Can you please DM me your tenant name and a exact UTC time stamp sample when your gateway makes the request to Auth0?

---

<div class="post-metadata">

**Author:** ![smirauta](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/smirauta/32/15135_2.png) [@smirauta](https://community.auth0.com/u/smirauta)\
**Post date:** [August 10, 2021, 10:51am UTC](https://community.auth0.com/t/issuer-with-custom-domain-in-m2m-token/66050/5 "2021-08-10T10:51:51Z")

</div>

Hi Sidharth,  
Just letting you know that the issue was fixed on our side in the gateway configuration.  
Thank you!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [August 11, 2021, 10:29am UTC](https://community.auth0.com/t/issuer-with-custom-domain-in-m2m-token/66050/6 "2021-08-11T10:29:51Z")

</div>

Perfect! Glad to hear that!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [August 26, 2021, 9:22am UTC](https://community.auth0.com/t/issuer-with-custom-domain-in-m2m-token/66050/7 "2021-08-26T09:22:11Z")

</div>


