Skip to content

Providing an HttpClient

Bogdan Gavril edited this page Aug 15, 2019 · 4 revisions

Starting in Adal 5.0.1-preview you will be able to provide your own Httpclient to enable fine grained control on the Http proxy. ASP.NET has efficient ways of pooling the HttpClient instance. For details see Use HttpClientFactory to implement resilient Http requests.

A new interface IHttpClientFactory to pass-in the HttpClient will be used by ADAL.NET to communicate with the endpoints of the Microsoft Identity platform for developers.

Here's an example of how to use the interface:

IHttpClientFactory myHttpClientFactory = new MyHttpClientFactory();

AuthenticationContext authenticationContext = new AuthenticationContext(
     authority: "",
     validateAuthority: true,
     tokenCache: <some token cache>,
     httpClientFactory: myHttpClientFactory);

HttpClient and Xamarin iOS

When using Xamarin iOS, it is recommended to create an HttpClient that explicitly uses the NSURLSession-based handler for iOS 7 and newer. ADAL.NET will automatically create an HttpClient that uses NSURLSessionHandler for iOS 7 and newer. See the Xamarin iOS documentation for HttpClient for more information.

Clone this wiki locally
You can’t perform that action at this time.