# Audience on Auth0 Gem

**URL:** <https://community.auth0.com/t/audience-on-auth0-gem/50695>\
**Category:** Get Help\
**Tags:** api, custom-domain\
**Created:** [September 30, 2020, 5:05am UTC](https://community.auth0.com/t/audience-on-auth0-gem/50695 "2020-09-30T05:05:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nils](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nils/32/20401_2.png) [@nils](https://community.auth0.com/u/nils)\
**Post date:** [September 30, 2020, 5:05am UTC](https://community.auth0.com/t/audience-on-auth0-gem/50695/1 "2020-09-30T05:05:49Z")

</div>

I think I found the base solution for a problem I have, it’s the same as in “[Unable to authorized with the custom domain](https://community.auth0.com/t/unable-to-authorized-with-the-custom-domain/10020)” **BUT** I’m not using the Management API directly, I’m using the gem [auth0](https://rubygems.org/gems/auth0). I’m not sure about the code I need to add to change the audience on my case.

How can I change the audience using the “gem”. My current code looks like:

```ruby
...
  authInfo = auth0_client.user(userId)
...
  def auth0_client
    Auth0Client.new(
      client_id: ENV['AUTH0_CLIENT_ID'],
      client_secret: ENV['AUTH0_CLIENT_SECRET'],
      domain: ENV['AUTH0_DOMAIN'], # Like auth.mydomain.com
      api_version: 2,
      timeout: 5
    )
  end

```

I’m not sure how to specify both domains, the custom one and the auth0 default (as stated in the answer [Unable to authorized with the custom domain - #3 by kimcodes](https://community.auth0.com/t/unable-to-authorized-with-the-custom-domain/10020/3)). Maybe is not in the initializer but in another method to add extra headers, perhaps like this?:

```ruby
...
authInfo.add_headers( audience: ENV['AUTH0_DEFAULT_DOMAIN'] ) # Like mydomain.auth0.com
...

```

---

<div class="post-metadata">

**Author:** ![joseantonio.rey](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/joseantonio.rey/32/14670_2.png) [@joseantonio.rey](https://community.auth0.com/u/joseantonio.rey)\
**Post date:** [September 30, 2020, 1:41pm UTC](https://community.auth0.com/t/audience-on-auth0-gem/50695/2 "2020-09-30T13:41:52Z")

</div>

Hello, @nils,

As stated in the document below, the Management API does not accept the custom domain as its domain, only the tenant domain.

> **[Configure Features to Use Custom Domains](https://auth0.com/docs/customize/custom-domains/configure-features-to-use-custom-domains)**
>
> Learn how to configure a custom domain for Auth0 authentication features.

The identifiers for the Auth0 APIs will still be the same, it’s just that traffic can now come through the custom domain.

Let me know if this helps.

---

<div class="post-metadata">

**Author:** ![nils](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nils/32/20401_2.png) [@nils](https://community.auth0.com/u/nils)\
**Post date:** [September 30, 2020, 1:52pm UTC](https://community.auth0.com/t/audience-on-auth0-gem/50695/3 "2020-09-30T13:52:48Z")

</div>

Thanks a lot, 🤦‍♂️ I look at this for hours and I totally missed this paragraph in the section you linked to me:

> Note that the Management API only accepts Auth0 domains. If you use a custom domain and also intend to perform [Management API actions with Auth0.js](https://auth0.com/docs/libraries/auth0js/v9#user-management), you must instantiate a new copy of `webAuth` using your Auth0 domain.

I’ll try it now and mark the solution. Thanks.

---

<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:** [October 1, 2020, 1:37pm UTC](https://community.auth0.com/t/audience-on-auth0-gem/50695/4 "2020-10-01T13:37:54Z")

</div>

No worries! We’ve all been there!

---

<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:** [October 16, 2020, 1:38pm UTC](https://community.auth0.com/t/audience-on-auth0-gem/50695/5 "2020-10-16T13:38:07Z")

</div>

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