Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kf_setImageWithURL with Authentication Challenge ? #226

Closed
hshah2811 opened this issue Feb 1, 2016 · 4 comments
Closed

kf_setImageWithURL with Authentication Challenge ? #226

hshah2811 opened this issue Feb 1, 2016 · 4 comments

Comments

@hshah2811
Copy link

My app is using below API to download image async manner.

public func kf_setImageWithURL(URL: NSURL, placeholderImage: UIImage?, optionsInfo: Kingfisher.KingfisherOptionsInfo?, completionHandler: Kingfisher.CompletionHandler?) -> Kingfisher.RetrieveImageTask

Problem i am facing is - how to provide authentication challenge response if my server is requesting to download any response. I know there are ways in normal NSURLConnection connection with delegate -
(void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler

Is there any way in kingfisher where i can provide my credential before downloading image?

@onevcat
Copy link
Owner

onevcat commented Feb 2, 2016

If you are using NSURLAuthenticationMethodServerTrust, you can add your server host to trustedHosts of ImageDownloader to mark your server trusted:

ImageDownloader.defaultDownloader.trustedHosts!.insert("yourhost.com")

And if you are using HTTP basic authentication, you could just modify the request by injecting with requestModifier of the downloader.

However, if you are using other authentication methods, like client certificate, currently there is no way in Kingfisher for it.

I believe we should add a delegate of it for better extensibility. I will check it to see whether I could do something on this later.

@onevcat
Copy link
Owner

onevcat commented Feb 27, 2016

Now you should be able to use authenticationChallengeResponder for it.

@onevcat
Copy link
Owner

onevcat commented Mar 10, 2016

Version 2.1.0 is released, which contains this feature.

@onevcat onevcat closed this as completed Mar 10, 2016
@TNikolai
Copy link

@onevcat Could you write example how to use authenticationChallengeResponder, basicaly i want to download image like this :
imageView.kf_setImageWithURL(url, placeholderImage: UIImage(named: PlaceHolderImageName))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants