Open SWarnberg opened 1 year ago
I was trying to deep-dive into this topic and a quick solution might be extending the GrpcHttpClientBuilderExtensions
with a new method more or less like this:
public static IHttpClientBuilder AddDownstreamWebApi(this IHttpClientBuilder builder, string serviceName,
DownstreamWebApiOptions configuration)
{
builder.EnableTokenAcquisitionToCallDownstreamApi();
builder.Services.Configure<DownstreamWebApiOptions>(serviceName, configuration);
builder.Services.AddHttpClient<IDownstreamWebApi, DownstreamWebApi>();
return builder;
}
but this means that the Grpc.Net.ClientFactory project should contain a dependency to Microsoft.Identity.Web
and not sure if this should be the case.
Describe the solution you'd like
For OBO flows there's an excellent extension method when an API calls another API,
AddDownstreamWebApi
. However, even though gRPC clients use HttpClient internally, this extension doesn't seem to work. It would be great to get a similar extension, or same, to work with gRPC clients in ASP.NET Core.Describe alternatives you've considered
Today we're using
AddCallCredentials
with code for getting the token manually usingITokenAcquisition
.Additional context
Referred scenario: A web API that calls web APIs Current solution: Bearer token with gRPC client factory