Filter Users by role and metadata
hantsy opened this issue · 9 comments
I used https://github.com/auth0/auth0-java in my project(Spring Boot 3.0/Java 17/Kotlin), try to filter users by role and app metadata.
val roleId = api.roles().list(RolesFilter()).execute().items.firstOrNull { it.name == roleName }?.id
....
val users=api.roles().listUsers(roleId, PageFilter().withPage(offset / limit, limit).withTotals(true)).execute() ```
But `PageFilter` can not add app metadata as filter condition.
👋 Hi @hantsy, I don't see any filter params available on the API to that pertain to app metadata? It appears the endpoint only supports paging params: https://auth0.com/docs/api/management/v2#!/Roles/get_role_user
Let us know if I'm looking at the wrong endpoint or if you are able to apply filters to the endpoint that aren't documented. Thanks!
There is a requirement from our project.
We need to filter users by role and some specific attributes(we save them into the app_metadata when we created a user).
@hantsy are you requesting a new feature to the management API, or for this SDK to support an existing feature in the Management API? If the API supports this ability, please provide an example of it so we can understand if/why it is not documented as part of the public API. If it's not available in the API, you should work with your sales rep to request the feature or work with support. Thanks!
Hi @jimmyjames,
Can we suggest updating the SDK to reflect the management API?
I.e. for the ListByEmail
method, it indicates that you can pass any filter to it
However, from the API there is no option to pass a filter, so the SDK should also not let a filter parameter be added.
https://auth0.com/docs/api/management/v2#!/Users_By_Email/get_users_by_email
Hi @daniel-johns-99 - the get_users_by_email
endpoint does allow a fields filter, see the parameters section beneath the API description:
@hantsy just to follow up, the get a role's users endpoint does not support filtering by role or or app metadata (unless I'm missing something, but I don't see that available). The PageFilter
is used to configure the paging options as described in the API's documentation.
If you wish the endpoint to support this feature, you should work with support as mentioned.
Unless there is additional info I'm missing, I'll plan on closing this issue end of week. Thanks!
There is no APIs to search users by roles and user attributes at the same time. OK, will ask Auth0 support, we paid the auth0 service in the production.
@hantsy I was having the same problem, I've created a feature request for it. You can vote for it here: https://community.auth0.com/t/ability-to-specify-users-role-in-search-criteria-in-users-list-endpoint/99873
Great, thanks @hantsy and @kronaemmanuel! I'm going to close this issue; if changes are made to the API to support the feature we can then add support to the SDK.