Auth0 Home Blog Docs

Management API - retrieve users by audience

management-api
users
audience
manage-users

#1

Assume I have more than one audience set up - say there’s a separate DEV audience. I’m trying to restrict the list of users from the API (api/v2/users) by audience. Is that possible? Is there a different way of accomplishing this?


#2

I’m a bit confused by your reference to audience because that is currently a parameter that is used to request authorization to a specific API (aka resource server) configured in the APIs section of the dashboard. If that was what you refer to then have in mind the user profile by default does not contain any information about audiences so from that perspective it would be a no.

The user search functionality that the endpoint in question allows for is described here. As you’ll see you can perform searches over a specific set of fields and only older tenants have the ability to perform searches over a wider set of fields including dynamic properties.


#3

@jmangelo
Thanks for your comment. I am confused too. Here’s how I ended up asking what I asked:

  • I have created 2 clients

  • I have created 2 API’s

  • I authorized one of the API’s to use Auth0 Management API

  • I copied the new API’s key and secret and I’m using them in to retrieve /v2/users.
    I’m using this node package (https://github.com/auth0/node-auth0) to generate the access key and connections like this:

    return new ManagementClient({
    domain: process.env.AUTH0_DOMAIN,
    clientId: process.env.AUTH0_API_ID,
    clientSecret: process.env.AUTH0_API_SECRET
    });
    where audience is my top level account, and the ID & Secret are the new API’s (as opposed to Auth0 Management API directly

  • I receive users from the other client / the other database as well, clients I thought were not connected.

I have gone through the connections on the clients and API’s to see if I had enabled anything anywhere but that does not seem to be the case. I’m not sure what I’m doing wrong.


#4

I have since tried to add audience to the above authorization call, but this leads to errors such as "error":"access_denied","error_description":"Service not enabled within domain: https://my-api-identifier.com.auth0.com/api/v2/"


#5