You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GetAllInvitationsAsync always returns zero for length, issue appears be a result of /src/Auth0.ManagementApi/Paging/PagedListConverter.cs when only limit is present (as with management API endpoint https://{tenant}/api/v2/organizations/{org_id}/invitations?include_totals=true), the page size is incorrectly set to 0.
Reproduction
Sample showing discrepancy of SDK vs management API
using Auth0.ManagementApi;
using Auth0.ManagementApi.Models;
using Auth0.ManagementApi.Paging;
using Microsoft.Extensions.Configuration;
using System.Text.Json;
class Program
{
static async Task Main()
{
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();
var token = await GetToken(config);
var client = new ManagementApiClient(token, new Uri($"https://{config["Auth0:Domain"]}/api/v2"));
var organizationId = config["Auth0:OrganizationId"];
var pagination = new PaginationInfo(0, 50, true);
var request = new OrganizationGetAllInvitationsRequest();
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {token}");
var rawResponse = await httpClient.GetAsync(
$"https://{config["Auth0:Domain"]}/api/v2/organizations/{organizationId}/invitations?page=0&per_page=50&include_totals=true");
Console.WriteLine("Raw API Response:");
Console.WriteLine(await rawResponse.Content.ReadAsStringAsync());
var invitations = await client.Organizations.GetAllInvitationsAsync(organizationId, request, pagination);
Console.WriteLine("\nSDK Parsed Results:");
if (invitations is IPagedList<OrganizationInvitation> pagedList)
{
Console.WriteLine($"Start: {pagedList.Paging?.Start}");
Console.WriteLine($"Length: {pagedList.Paging?.Length}");
Console.WriteLine($"Items Count: {invitations.Count()}");
}
}
static async Task<string> GetToken(IConfiguration config)
{
var tokenRequest = new
{
client_id = config["Auth0:ClientId"],
client_secret = config["Auth0:ClientSecret"],
audience = $"https://{config["Auth0:Domain"]}/api/v2/",
grant_type = "client_credentials"
};
var httpClient = new HttpClient();
var response = await httpClient.PostAsync(
$"https://{config["Auth0:Domain"]}/oauth/token",
new StringContent(JsonSerializer.Serialize(tokenRequest), System.Text.Encoding.UTF8, "application/json"));
var tokenResponse = await response.Content.ReadAsStringAsync();
return JsonDocument.Parse(tokenResponse).RootElement.GetProperty("access_token").GetString();
}
}
Additional context
No response
auth0.net version
7.330
.NET version
8.0.405
The text was updated successfully, but these errors were encountered:
Hi @luch0-dev
Seems the response has just the start and limit values and that's the reason the rest of the values default to 0.
Also in the documentation there is another call-out as follows We do not yet support returning the total invitations count. from the API.
Let us know if this clarifies your issue.
Checklist
Description
GetAllInvitationsAsync always returns zero for length, issue appears be a result of /src/Auth0.ManagementApi/Paging/PagedListConverter.cs when only
limit
is present (as with management API endpoint https://{tenant}/api/v2/organizations/{org_id}/invitations?include_totals=true), the page size is incorrectly set to 0.Reproduction
Sample showing discrepancy of SDK vs management API
Additional context
No response
auth0.net version
7.330
.NET version
8.0.405
The text was updated successfully, but these errors were encountered: