I’m looking into using the Auth0 .NET SDK to access the management API. The operations that I’ll need to access are get user and create user for now. Looking at the SDK documentation: Auth0 .NET SDK I’m wondering if it’s possible to apply Polly retry policy to the HttpClient used by the HttpClientManagementConnection. From this documentation, Class HttpClientManagementConnection it seems that the constructor receives an HttpClient object.
I wonder if the following code on Startup would enforce retry policy to the HttpClient used by the HttpClientManagementConnection. It uses the AddHttpClient extension from .NET Core:
I’m not sure how to test if the retry is working
Will try to research that but I’m not .NET guy, maybe someone else from the community will be able share some tips
I did more test and apparently injecting it like that doesn’t work. There’s no retry happening… i need to figure out how to inject the HttpClient into ManagementConnection in another way
Using Func in dependency injection and injecting the HttpClient there seems to work
.AddPolicyHandler((services, request) => GetRetryPolicy<UserProvider>(services, request));
var httpClientFactory = serviceProvider.GetService<IHttpClientFactory>();
var httpClient = httpClientFactory.CreateClient(UserProviderHttpClientName);
return new HttpClientManagementConnection(httpClient);
Glad you have figured it out and thanks for sharing with the rest of community!