How to get API token for fetching User Details in Blazor Application?

Hi Team,

My requirement is to fetch the list of register users for my application. I am implementing in Blazor Web 8.0.

I am not getting Api tokenId. Could please review my code snippets and let me what is the problem?

If there will any blog post document on this. Please share with me. Here is my code snippets.

private readonly HttpClient _httpClient;
private readonly IConfiguration _configuration;
public UserManagementService(HttpClient httpClient, IConfiguration configuration)
{
    _httpClient = httpClient;
    _configuration = configuration;
}
public async Task<string> GetApiTokenAsync()
{
    var domain = _configuration["Auth0:Domain"];
    var clientId = _configuration["Auth0:ClientId"];
    var clientSecret = _configuration["Auth0:ClientSecret"];

    var request = new HttpRequestMessage(HttpMethod.Post, $"https://dev-cd3l76wi.us.auth0.com/oauth/token")
    {
        Content = new StringContent(JsonSerializer.Serialize(new
        {
            client_id = clientId,
            client_secret = clientSecret,
            audience = $"https://dev-cdf3l756gwi.us.auth0.com/api/v2/",
            grant_type = "client_credentials"
        }), Encoding.UTF8, "application/json")
    };

    var response = await _httpClient.SendAsync(request);
    response.EnsureSuccessStatusCode();

    var json = await response.Content.ReadAsStringAsync();
    var result = JsonSerializer.Deserialize<JsonElement>(json);
    return result.GetProperty("access_token").GetString();
}