diff --git a/JsonRpc.Http/HttpRpcClientHandler.cs b/JsonRpc.Http/HttpRpcClientHandler.cs index 4d77854..373f88d 100644 --- a/JsonRpc.Http/HttpRpcClientHandler.cs +++ b/JsonRpc.Http/HttpRpcClientHandler.cs @@ -66,6 +66,12 @@ public Encoding Encoding /// Content-Type header value, or null to suppress Content-Type header. public string ContentType { get; set; } = "application/json-rpc"; + /// + /// Authentication token header value. + /// + /// Bearer Authentication token header value. + public string AuthToken { get; set; } + // Looking for EmitContentCharset? No, StringContent will automatically append charset to the // end of the Content-Type of the requests. @@ -95,6 +101,11 @@ protected virtual HttpRequestMessage GetHttpRequestMessage(RequestMessage reques }; if (!string.IsNullOrEmpty(UserAgent)) req.Headers.UserAgent.ParseAdd(UserAgent); req.Headers.UserAgent.Add(new ProductInfoHeaderValue("JsonRpc.Http", "0.3")); + if (!string.IsNullOrEmpty(AuthToken)) + { + req.Headers.Authorization = new AuthenticationHeaderValue("Bearer", AuthToken); + } + return req; }