Auth0 Home Blog Docs

Node-auth0 ManagementClient vs UsersManager et al

node-auth0

#1

I started working on a new general purpose Management API command line interface, using oclif and node-auth0 because, what else is there to do over the holiday season?! I haven’t pushed it to NPM or posted it in Show Your Auth0 yet because the code is a mess. I mean, I assume it’s a mess since I have almost no idea what I’m doing. I am completely new to node / typescript / javascript.

In general, is it recommended to call the methods of the ManagementClient object, such as getUser, vs. the methods of other objects like UsersManager and its users.get? ManagementClient methods seem to be wrappers around those other objects/methods.

Also, which node-auth0 method is used to query the user database? The only options seem to be ‘get a user by their user_id’, ‘get a user by their email address’, and ‘get all users’ (which must not even work for more than 1,000 users?) Maybe I’ve been staring at this too long but I can’t seem to find the appropriate method.


#2

getAll makes a request to the /api/v2/users endpoint for which you can specify a search parameter. See https://auth0.com/docs/api/management/v2#!/Users/get_users for an explanation of parameter, but a sample request would look like this:

managementClient.getUsers( {
  search_engine:'v3',
  q: 'name:john*'
}, callback);

Take a look at https://auth0.com/docs/users/search/v3/query-syntax#searchable-fields for more details on the query search syntax.

As for using managementClient.getUsers or managementClient.users.getAll, it seems that the readme.md documentation favors the first approach (although I’m not speaking for the SDK team).


#3

Thanks @nicolas_sabena. The node-auth0 docs only mentions setting per_page and page, but I know the API well enough that I should have just tried it anyway.

If I get a chance, I’ll submit a PR to update the documentation.