diff --git a/src/Auth0.ManagementApi/Models/OrganizationGetAllMembersRequest.cs b/src/Auth0.ManagementApi/Models/OrganizationGetAllMembersRequest.cs index 711f5cdd6..e8dc8ffc6 100644 --- a/src/Auth0.ManagementApi/Models/OrganizationGetAllMembersRequest.cs +++ b/src/Auth0.ManagementApi/Models/OrganizationGetAllMembersRequest.cs @@ -5,6 +5,13 @@ public class OrganizationGetAllMembersRequest { /// /// A comma separated list of fields to include or exclude (depending on ) from the result, empty to retrieve all fields. /// + /// + /// If fields is left blank, all fields (except roles) are returned. + /// + /// Member roles are not sent by default. + /// Use fields=roles to retrieve the roles assigned to each listed member. + /// To use this parameter, you must include the read:organization_member_roles scope in the token. + /// public string Fields { get; set; } = null; /// diff --git a/src/Auth0.ManagementApi/Models/OrganizationMember.cs b/src/Auth0.ManagementApi/Models/OrganizationMember.cs index 175ff8141..6d55de9b5 100644 --- a/src/Auth0.ManagementApi/Models/OrganizationMember.cs +++ b/src/Auth0.ManagementApi/Models/OrganizationMember.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Collections.Generic; +using Newtonsoft.Json; namespace Auth0.ManagementApi.Models { @@ -27,5 +28,11 @@ public class OrganizationMember /// [JsonProperty("email")] public string Email { get; set; } + + /// + /// The roles of the user + /// + [JsonProperty("roles")] + public IList Roles { get; set; } } } diff --git a/tests/Auth0.ManagementApi.IntegrationTests/OrganizationTests.cs b/tests/Auth0.ManagementApi.IntegrationTests/OrganizationTests.cs index a15f91c18..cf5563281 100644 --- a/tests/Auth0.ManagementApi.IntegrationTests/OrganizationTests.cs +++ b/tests/Auth0.ManagementApi.IntegrationTests/OrganizationTests.cs @@ -330,6 +330,10 @@ public async Task Test_organization_member_roles_crud_sequence() roles.Count.Should().Be(1); roles[0].Name.Should().Be("Admin"); + var response = await fixture.ApiClient.Organizations.GetAllMembersAsync(ExistingOrganizationId, new OrganizationGetAllMembersRequest { Fields = "roles", IncludeFields = true }, new Paging.PaginationInfo()); + + response[0].Roles[0].Name.Should().Be("Admin"); + await fixture.ApiClient.Organizations.DeleteMemberRolesAsync(ExistingOrganizationId, user.UserId, new OrganizationDeleteMemberRolesRequest { Roles = new List { ExistingRoleId }