Re: Questions on when credentials are used in NSURLSessionDownloadTask
On 21 Apr 2015, at 03:28, Daryle Walker <darylew@mac.com> wrote:
When creating a credential with username “hello” and password “there,” the former URL succeeds (200) while the latter fails (401).
This works for me now, both in Safari and in code. Here's my challenge handler: - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential *))completionHandler { if ( [ @[ NSURLAuthenticationMethodDefault, NSURLAuthenticationMethodHTTPBasic, NSURLAuthenticationMethodHTTPDigest, NSURLAuthenticationMethodNTLM ] containsObject:challenge.protectionSpace.authenticationMethod] ) { completionHandler( NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialWithUser:@"hello" password:@"there" persistence:NSURLCredentialPersistenceForSession ]); } else { completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); } } Share and Enjoy -- Quinn "The Eskimo!" <http://www.apple.com/developer/> Apple Developer Relations, Developer Technical Support, Core OS/Hardware _______________________________________________ Do not post admin requests to the list. They will be ignored. Macnetworkprog mailing list (Macnetworkprog@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/macnetworkprog/site_archiver%40lists... This email sent to site_archiver@lists.apple.com
participants (1)
-
Quinn "The Eskimo!"