'How to search all users using certain search criteria within user_metadata in auth0?

I would like to search all users which match certain search criteria within user_metadata. How should I go about doing this?

i.e. search all Auth0 users using UsersPage or equivalent function which allows us to filter users based on key/value pairs defined in user_metadata?

// sample scenarios
Scenario 1:

Auth0 organization feature is available and veeDNA authentication module will use it

The above implies there will be a separate organization for each tenant

auth0-org-a, user-a1 metadata will contain the mapping for tenant-id-a

auth0-org-a, user-a2 metadata will contain the mapping for tenant-id-a

auth0-org-b, user-b1 metadata will contain the mapping for tenant-id-b

auth0-org-b, user-b2 metadata will contain the mapping for tenant-id-b

i.e. each Auth0 organization will contain its own users

Scenario 2:

Auth0 organization feature is available and veeDNA authentication module will use it

We will use a single organization for all tenants

auth0-org , user-a1 metadata will contain the mapping for tenant-id-a

auth0-org , user-a2 metadata will contain the mapping for tenant-id-a

auth0-org , user-b1 metadata will contain the mapping for tenant-id-b

auth0-org , user-b2 metadata will contain the mapping for tenant-id-b

i.e. the only default Auth0 organization will contain all users


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source