Код: Выделить всё
var clientFactory = services.BuildServiceProvider().GetRequiredService();
services.AddHttpClient()
.AddHttpMessageHandler(() =>
{
var authorization = new BearerAuthorization(clientFactory, clientId, clientSecret, authHost, token);
return new AuthorizationHandler(authorization);
});
Код: Выделить всё
_typedClient = serviceProvider.GetRequiredService();
await _typedClient.SendRequest(); // OK
Код: Выделить всё
_httpClientFactory = serviceProvider.GetRequiredService();
_typedClientFactory = serviceProvider.GetRequiredService();
using var client = _httpClientFactory.CreateClient();
using var typedClient = _typedClientFactory.CreateClient(client);
await typedClient.SendRequest(); // Fail
Подробнее здесь: https://stackoverflow.com/questions/789 ... agehandler
Мобильная версия