Skip to content
This repository has been archived by the owner on Jun 30, 2023. It is now read-only.

Providing an HttpClient

Bogdan Gavril edited this page Oct 28, 2020 · 5 revisions

Using a Proxy

ADAL uses the default system configuration when communicating with the Internet, via HttpClient. 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.

HttpClient in high load apps

ASP.NET has efficient ways of pooling the HttpClient instance. For details see Use HttpClientFactory to implement resilient Http requests.

Using a custom HttpClient

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: "https://login.microsoftonline.com/common",
     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