-
Notifications
You must be signed in to change notification settings - Fork 253
Expand file tree
/
Copy pathMsalMtlsHttpClientFactory.cs
More file actions
33 lines (28 loc) · 1.15 KB
/
MsalMtlsHttpClientFactory.cs
File metadata and controls
33 lines (28 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System.Net.Http;
using System.Security.Cryptography.X509Certificates;
using Microsoft.Identity.Client;
namespace Microsoft.Identity.Web
{
internal sealed class MsalMtlsHttpClientFactory : IMsalMtlsHttpClientFactory
{
private readonly IMsalMtlsHttpClientFactory _httpClientFactory;
public MsalMtlsHttpClientFactory(IMsalMtlsHttpClientFactory httpClientFactory)
{
_httpClientFactory = httpClientFactory;
}
public HttpClient GetHttpClient()
{
HttpClient httpClient = _httpClientFactory.GetHttpClient();
httpClient.DefaultRequestHeaders.Add(Constants.TelemetryHeaderKey, IdHelper.CreateTelemetryInfo());
return httpClient;
}
public HttpClient GetHttpClient(X509Certificate2 x509Certificate2)
{
HttpClient httpClient = _httpClientFactory.GetHttpClient(x509Certificate2);
httpClient.DefaultRequestHeaders.Add(Constants.TelemetryHeaderKey, IdHelper.CreateTelemetryInfo());
return httpClient;
}
}
}