Audience on Auth0 Gem

I think I found the base solution for a problem I have, it’s the same as in “Unable to authorized with the custom domainBUT I’m not using the Management API directly, I’m using the gem 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:

...
  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). Maybe is not in the initializer but in another method to add extra headers, perhaps like this?:

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

Hello, @nils,

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

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.

3 Likes

Thanks a lot, :man_facepalming: 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, you must instantiate a new copy of webAuth using your Auth0 domain.

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

1 Like

No worries! We’ve all been there!

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