Firebase: Get users for linked to a specific tenant

Viewed 37

We're using our auth backend for multiple customers. The idea would be to create a tenant for every customer account. For user management purposes, I need to display a list of all available users in the front end.

As I can't just display all available users, I'm looking for a way on how to retrieve a specific group of users.

getUsers() (https://firebase.google.com/docs/auth/admin/manage-users#bulk_retrieve_user_data) doesn't help, as there is no UserIdentifier for custom claims (which would be a way to differentiate between accounts).

Another idea (as mentioned) would be to create a tenant for every account, and map the users that belong to this account. But it seems like there's no method to get all users for a tenant as well.

Of course I could just store user data in firestore as well, but I'm curious if there's a different way.

Thanks in advance for your help!

1 Answers

The documentation for Google Cloud Identity Platform seems to indicate that it is possible to get a list of the users for a specific tenant by calling listUsers on an auth instance that is initialized for that specific tenant with:

const tenantAuth = admin admin.auth().tenantManager().authForTenant('TENANT-ID');

tenantAuth.listUsers(1000, nextPageToken)
    .then((listUsersResult) => {
      ...
    })
Related