title: FFImageLoading: How to add authentication?
body: <p>I'm trying to use <a href="https://github.com/luberda-molinet/FFImageLoading/wiki" rel="nofollow noreferrer">FFImageLoading</a> in my Xamarin.iOS and Xamarin.Android apps to load images from url. All the url's require authentication..</p>
  
  <p>Also I'm using <code>modernhttpclient</code> for all other Rest Calls. For <code>modernhttpclient</code> this is how I'm adding authentication</p>
  
  <pre><code>var cookieHandler = new NativeCookieHandler ();
  var messageHandler = new NativeMessageHandler (false, false, cookieHandler);
  cookieHandler.SetCookies (RestApiPaths.cookies);
  using (var client = new HttpClient (messageHandler)) {
  client.DefaultRequestHeaders.TryAddWithoutValidation ("User-Agent", GetUserAgent (platform));
  var r = await client.GetAsync (new Uri (url));
  </code></pre>
  
  <p>and it is working very well. I did same thing for FFImageLoading, </p>
  
  <pre><code>var cookieHandler = new NativeCookieHandler ();
  var messageHandler = new NativeMessageHandler (false, false, cookieHandler);
  cookieHandler.SetCookies (RestApiPaths.cookies);
  var client = new HttpClient (messageHandler);
  client.DefaultRequestHeaders.TryAddWithoutValidation ("User-Agent", RestApiPaths.GetUserAgent (Constants.__IOS__));
  
  ImageService.Instance.Initialize (new Configuration {
      HttpClient = client
  });
  
  ImageService.Instance.LoadUrl (url).Into (ArticleImageView);
  </code></pre>
  
  <p>but unfortunately, it is not working. No image get loaded. I know it is problem with authentication. I tried with another url which does not require authentication and its working. Can someone please tell what should I do to get it working.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I tried this from <a href="https://github.com/luberda-molinet/FFImageLoading/wiki/Authentication-Support" rel="nofollow noreferrer">Authentication-Support</a></p>
  
  <pre><code>public class AuthenticatedHttpImageClientHandler : HttpClientHandler
  {
  
      public AuthenticatedHttpImageClientHandler()
      {
  
      }
  
      protected override async Task&lt;HttpResponseMessage&gt; SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
      {
          request.Headers.Add("Cookie", RestApiPaths.cookie);
          request.Headers.Add("User-Agent", RestApiPaths.GetUserAgent(Constants.__IOS__));
          return await base.SendAsync(request, cancellationToken).ConfigureAwait(false);
      }
  }
  </code></pre>
  
  <p>then:</p>
  
  <pre><code>ImageService.Instance.Initialize (new Configuration {
      HttpClient = new HttpClient(new AuthenticatedHttpImageClientHandler())
  });
  </code></pre>
  
  <p>but still not working..</p>