From e53483c231c7a78585436f06a3350579c9062afd Mon Sep 17 00:00:00 2001 From: Fabian Martinez <46371672+famarting@users.noreply.github.com> Date: Thu, 7 Sep 2023 12:28:00 +0200 Subject: [PATCH] set dapr-api-token to healthz requests when needed Signed-off-by: Fabian Martinez <46371672+famarting@users.noreply.github.com> --- src/Dapr.Client/DaprClientGrpc.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Dapr.Client/DaprClientGrpc.cs b/src/Dapr.Client/DaprClientGrpc.cs index 79f7f59ae..75df09323 100644 --- a/src/Dapr.Client/DaprClientGrpc.cs +++ b/src/Dapr.Client/DaprClientGrpc.cs @@ -1743,6 +1743,12 @@ public override async Task CheckHealthAsync(CancellationToken cancellation { var path = "/v1.0/healthz"; var request = new HttpRequestMessage(HttpMethod.Get, new Uri(this.httpEndpoint, path)); + + if (this.apiTokenHeader is not null) + { + request.Headers.Add(this.apiTokenHeader.Value.Key, this.apiTokenHeader.Value.Value); + } + try { using var response = await this.httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken); @@ -1759,6 +1765,12 @@ public override async Task CheckOutboundHealthAsync(CancellationToken canc { var path = "/v1.0/healthz/outbound"; var request = new HttpRequestMessage(HttpMethod.Get, new Uri(this.httpEndpoint, path)); + + if (this.apiTokenHeader is not null) + { + request.Headers.Add(this.apiTokenHeader.Value.Key, this.apiTokenHeader.Value.Value); + } + try { using var response = await this.httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken);