Find members from organization with specific role

Hi,

When Organizations Feature is released we started to migrating some apis to enable us to use new feature

In one specific task, I used that API(/api/v2/roles/{id}/users) to get all Users by Role.

Today I need find all Members from Organization with specific role id/name.

Like that: /api/v2/organizations/{id}/members/{role id/name}

but that API don’t exists, someone can help us with that? or this is impossible today? Finding all members of organization and get permissions each of them is some inviable.

6 Likes

Hi @elton.nunes.sysmap,

The endpoint you describe doesn’t exist at this time. Can you let us know how you would use it? What is the use-case you are looking to support?

2 Likes

Hi @adam.housman

I would use it to list all members with specific Role. I do that today with Roles API (/api/v2/roles/{id}/users) that API I can list all users with RoleID=xxxxxx, but using Organizations I cant do the same thing.

The use-case is, Today I use RBAC feature of Auth0 to control permissions inside my application, I want start use Organizations because is perfect to us who has a B2B Application, today I need create one Role with tenant name, for example “company1:guest”, “company2:guest”, and etc…

Now with Organizations I can create only one Role “guest” and assign that of each member on each Organization that he joined, that feature is perfect to us :slight_smile: (thanks Auth0 for that).

With that idea, I want show to administrators of each Organization what users has each Role that assigned on Organization, the administrator of Organization in one frontend choose Role “guest” in one select(combobox), and I want list all users with “guest” Role on Organization. Is a simple query

The point is, I can do that using the Roles API (/api/v2/roles/{id}/users), but with Organizations feature I can’t :frowning:

Thanks for your reply,
Elton Nunes

Thanks for that, @elton.nunes.sysmap - makes perfect sense. I’m flagging this thread and will let you know at such a time as we implement this endpoint.

1 Like

Thank you @adam.housman

Perfect,
See’ya :slight_smile:

You can estimate to me which time will take ?, because this endpoint is important to my solution, but if you can’t, no problem, I will implement in my side something to resolve that.

Hi @elton.nunes.sysmap we don’t have a target release date for this right now.

1 Like

Ok, no problem @adam.housman

Thank you by replies, patience and for your help,

Congrats for your Team by excellent product :slight_smile: :+1:

See you later!
Elton Nunes

1 Like

Hello. I am in need of the same thing as well. Is this in the roadmap of the product ? Or do you have an alternative that doesn’t imply doing tens of request to get the role of every user?

Thank you!

2 Likes

We ran into the same need - to be able to list organization members that have a particular role assigned.

On top of that, a complimentary API would be useful - one that would return a list roles assigned within an organization. Something like /api/v2/organizations/{id}/roles/.

We found a bad workaround - to list organization members, query each member’s roles, and then merge the list. Obviously, this doesn’t scale well with a growing list of members because of the per-member roundtrips.

@adam.housman Any update on prioritization of the original ask and if you’d consider adding an API like the one I suggested?

Thanks.

4 Likes

Hi @adam.housman,

We are in need of this endpoint as well. Since we’re allowing users to delete a role even if it’s assigned to a user/users. This is causing an error where the user is left without a role and can’t do anything inside of our app.

A response to this issue would be greatly appreciated.

PS: It’s worth mentioning that we had found a workaround for this but as @sbykov mentioned that doesn’t scale well, and in our case, it resulted in a 429: Too Many Requests error.

Thanks

2 Likes

Hi @adam.housman,

Any update on this API feature? We are also in the same boat. Our workaround has been to list all organization members then query each members for their roles but with growing user base this will not scale as the number of API calls to get all member roles will grow exponentially with each new user.

I think we can pass the fields that we need when making the API call. So we can include “roles” and then it will return all members along with their roles.
Here is a sample code using auth0 sdk

const auth0 = new ManagementClient({
  domain,
  clientId,
  clientSecret,
  audience,
});
const response = await auth0.organizations.getMembers({
    id: '<org_id>',
    include_fields: true,
    fields: 'roles,name',
    include_totals: true,
  });
  console.log(response.data);

I can confirm this worked for my use case. I couldn’t find any documentation that ‘roles’ is a valid field to pass in here based on what I read, but this did work.