getUser returns all users instead of the specified user_id

Hello,

I’m trying to lookup a single user given a user’s id or email. However, when calling getUser and specifying a user_id using the ManagementClient, the response appears to be every user instead of the single user I’m trying to lookup.

Here’s what I’m attempting:

var auth0 = new ManagementClient({
    ...
});

auth0.getUser({ user_id: "{USER ID}" }, (err, res) => {
        if (err) {
            console.log(err.message);
        }
        console.log(res);
});

I’ve tried passing an email address for user_id and then user_id from the user info on the dashboard without the "email|" prefix. Both returns every user.

I’ve been reading as much of the docs as my eyes can take from here:

  1. https://auth0.github.io/node-auth0/module-management.ManagementClient.html#getUser

  2. https://auth0.com/docs/api/management/v2#!/Users/get_users_by_id

Am I missing something completely obvious? Thanks for any help!

Turns out it was quite obvious.

I was using the wrong key in the object passed to getUser.

It should have read:

auth0.getUser({ id: "{USER ID}" }, (err, res) => {
        if (err) {
            console.log(err.message);
        }
        console.log(res);
});

NOT user_id

Glad you figured it out eventually!

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