I have a .NET 8 client code to call a gRPC service and it works perfectly on Windows. But when I compile and run the exact same project on macOS I get an RpcException with the error message:
Status(StatusCode="PermissionDenied", Detail="Bad gRPC response. HTTP status code: 403")
Is there any macOS-specific client configuration that needs to be done for macOS? Here is the code that I prepare the client with:
HttpClient httpClient = new(new SocketsHttpHandler()) {
BaseAddress = new Uri("https://..."),
DefaultRequestVersion = HttpVersion.Version20,
DefaultVersionPolicy = HttpVersionPolicy.RequestVersionExact,
Timeout = Timeout.InfiniteTimeSpan,
};
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
GrpcChannel channel = GrpcChannel.ForAddress("https://...", new GrpcChannelOptions() {
HttpClient = httpClient,
Credentials = ChannelCredentials.Create(new SslCredentials(), CallCredentials.FromInterceptor((c, metadata) => {
metadata.Add("Authorization", "Bearer " + token);
return Task.CompletedTask;
}))});
var client = new MyServiceClient(channel);
var call = client.Method(new Empty());
await foreach(var draft in downCall.ResponseStream.ReadAllAsync(stoppingToken)) {
...
}