Auth0 Home Blog Docs

Fetch list of users with auth0js

I am using auth0js in my app.

Now I need to fetch all users in order to show managers which of the users listed in the users table in the app have an account.

I have searched the docs (https://auth0.com/docs/libraries/auth0js/v9) and found nothing :frowning: .

Does that mean that I have to now user the API (https://auth0.com/docs/api/management/v2#!/Users/get_users) directly, even though I have created a const auth0Manage = new auth0.Management instance in auth0js?

Can I at least use auth0Manage.baseOptions.token or do I have to fetch a different one?

@alex.barbalex,

You are not going to be able to (or want to) give your client side app the ability to get all users from the management api. You will want to do this in your backend. Take a look at this FAQ for some more info about why: How do I use the Management API in my single page application?

You can also get all users without a number limit using a long running export job, which will return a file in JSON or CSV format: https://auth0.com/docs/api/management/v2#!/Jobs/post_users_exports

Alternatively, you can use the Import/Export extension: https://auth0.com/docs/extensions/user-import-export.

Does this answer your question?

Thanks,
Dan

Obviously I need to get more security aware…

And I just realized I only have to save the ID passed with login to my users table to know who has an account.

Thanks a lot, @dan.woda

@alex.barbalex,

That is one reason to keep the conversation going here on the Community. I am happy to give my input and source information from the rest of the team.

Let me know if you have questions about anything else!

Best,
Dan

1 Like

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