# Login via API with Custom Domains - invalid domain x for clientId y

**URL:** <https://community.auth0.com/t/login-via-api-with-custom-domains-invalid-domain-x-for-clientid-y/60042>\
**Category:** Get Help\
**Tags:** password, token, access-token, custom-domain, auth0\
**Created:** [March 25, 2021, 7:32am UTC](https://community.auth0.com/t/login-via-api-with-custom-domains-invalid-domain-x-for-clientid-y/60042 "2021-03-25T07:32:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fenio](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/fenio/32/16048_2.png) [@Fenio](https://community.auth0.com/u/Fenio)\
**Post date:** [March 25, 2021, 7:32am UTC](https://community.auth0.com/t/login-via-api-with-custom-domains-invalid-domain-x-for-clientid-y/60042/1 "2021-03-25T07:32:36Z")

</div>

Hi!,

I have introduced custom domain in Auth0. For the sake of the discussion, let’s say that my auth0 domain was:  
**[rafal.eu.auth0.com](http://rafal.eu.auth0.com)**  
and custom domain is  
**[login.rafal.com](http://login.rafal.com)**

Before custom domains, I used **${auth0.domain}/oauth/token** with password grant to login as a user via the API:

```
{
"client_id": "hidden",
"audience": "https://rafal.audience.com",
"username": "rafal@rafal.com",
"password": "123456",
"grant_type": "password",
"scope": "openid profile email"
}

```

With above I had no troubles generating a token. The token was issued with **auth0 domain**. Now, since I’ve introduced Custom Domains, I would like to login via the API with **custom domain** so the issuer of the token matches the one expected by my Backend services.

When I try to run the same request for custom domain, I get following error:  
Status code: 400  
{  
“error”: “invalid\_request”,  
“error\_description”: “Invalid domain ‘[login.rafal.com](http://login.rafal.com)’ for client\_id 'hidden”  
}

Did I do something wrong? Maybe I am missing some configuration. I read in the documentation that /oauth/token endpoint is compliant with custom domains.

Thank you in advance

---

<div class="post-metadata">

**Author:** ![Fenio](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/fenio/32/16048_2.png) [@Fenio](https://community.auth0.com/u/Fenio)\
**Post date:** [March 25, 2021, 7:37am UTC](https://community.auth0.com/t/login-via-api-with-custom-domains-invalid-domain-x-for-clientid-y/60042/2 "2021-03-25T07:37:12Z")

</div>

Solution: Invalid client Id. I mixed up the environments _facepalm_

---

<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:** [March 25, 2021, 10:44am UTC](https://community.auth0.com/t/login-via-api-with-custom-domains-invalid-domain-x-for-clientid-y/60042/3 "2021-03-25T10:44:07Z")

</div>

No worries! We’ve all been there! Thanks for sharing that with the rest of community!

---

<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:** [April 9, 2021, 10:44am UTC](https://community.auth0.com/t/login-via-api-with-custom-domains-invalid-domain-x-for-clientid-y/60042/4 "2021-04-09T10:44:45Z")

</div>

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