ConfigureHttpClient in AddGrpcClient configuration
See original GitHub issueWhat version of gRPC and what language are you using?
v2.36 C# .Net 5.0
What operating system (Linux, Windows,…) and version?
macOS 11.2.3
What runtime / compiler are you using (e.g. .NET Core SDK version dotnet --info
)
SDK Version: 5.0.102 Runtime: Microsoft.NETCore.App 5.0.2
What did you do?
The way I configure the GrpcClient with the IHttpClientBuilder to manage authorization is as follows:
services.AddGrpcClient<MyGrpcServiceClient>(options =>
{
options.Address = configureOptions.Address;
})
.ConfigureHttpClient(client =>
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Token);
});
What did you expect to see?
I expected the authorization header to be set, but it’s empty. This doesn’t seem to be executed anymore. I use this pattern also with .Net 3.1 projects. I have to admit, I can’t find this pattern in the docs, so I guess this pattern isn’t used very much.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
gRPC client factory integration in .NET
Provides a central location for configuring logical gRPC client instances. Manages the lifetime of the underlying HttpClientMessageHandler .
Read more >HTTP Client Configuration
ConfigureHttpClient provides a callback to customize the SocketsHttpHandler settings used for proxying requests. This will be called each time a cluster is ...
Read more >Registering a “typed” gRPC client with the ASP.NET Core ...
AddGrpcClient <GrpcService>();. At the moment I have the following code, which works fine: services.AddSingleton<IService, GrpcService>();.
Read more >Optimally Configuring ASP.NET Core HttpClientFactory
In this post, I'm going to show how to optimally configure a HttpClient using the new HttpClientFactory API in ASP.NET Core 2.1.
Read more >Configuring gRPC clients in .NET - Irina Dominte(Scurtu)
How to configure gRPC Clients in a global way. ... By default, the AddGrpcClient , configures the gRPC clients as being transient.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@JamesNK The interceptor with CallCredentials doesn’t work on macOS, because it demands a secure connection. This is how I did get it to work on macOS.
Also worth noting I’m using protobuf-net.Grpc, can I still use AddGrpcClient? I’m currently using GrpcChannel.FromAddress with grpc-web