0

I need to load images that required basic authentication. I am using SDWebImage. I have a directory that is open to the public and those images load correctly. When I try and load images from a directory that requires authentication, it never loads the image. Is it possible to pass a username and password for authentication? I have added the following code, but it doesn't appear to help:

SDWebImageManager.SharedManager.ImageDownloader.Username = "myusername";
SDWebImageManager.SharedManager.ImageDownloader.Password = "mypassword";

ivPic.SetImage(
    url: new NSUrl("https://www.example.com/secure/pic.jpg"),
    placeholder: UIImage.FromBundle("NotAvailable.jpg")
);

EDIT: I have now become desperate as I cannot seem to access the images in an authentication required folder no matter what. I found a link using a different package (FFImageLoading) that gives an example here, but I am not using a token only a username and password via Basic Authentication. How can I get what the '_authService.GetToken' is?

ImageService.Initialize(new Configuration { HttpClient = new HttpClient(new AuthenticatedHttpImageClientHandler(_authService.GetToken)) });
Cœur
  • 37,241
  • 25
  • 195
  • 267
Max
  • 19
  • 5

1 Answers1

0

It turns out that I could never access pictures in a different folder than the web service itself. Setting the username and password as mentioned above works (and is required, which I am not sure why) when the folder is inside of the web service I am authenticating through.

Max
  • 19
  • 5