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

Providing an HttpClient

jennyf19 edited this page Mar 28, 2019 · 5 revisions

Starting in Adal 5.0.1-preview (not yet released) 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.

IHttpClientFactory myHttpClientFactory = new MyHttpClientFactory();

AuthenticationContext authenticationContext = new AuthenticationContext(
     authority: "https://login.microsoftonline.com/common",
     validateAuthority: true,
     tokenCache: TokenCache.DefaultShared,
     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