• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Questions on when credentials are used in NSURLSessionDownloadTask
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Questions on when credentials are used in NSURLSessionDownloadTask


  • Subject: Re: Questions on when credentials are used in NSURLSessionDownloadTask
  • From: "Quinn \"The Eskimo!\"" <email@hidden>
  • Date: Tue, 21 Apr 2015 09:51:19 +0100

> On 21 Apr 2015, at 03:28, Daryle Walker <email@hidden> 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      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Questions on when credentials are used in NSURLSessionDownloadTask
      • From: Daryle Walker <email@hidden>
References: 
 >Questions on when credentials are used in NSURLSessionDownloadTask (From: Daryle Walker <email@hidden>)
 >Re: Questions on when credentials are used in NSURLSessionDownloadTask (From: "Quinn \"The Eskimo!\"" <email@hidden>)
 >Re: Questions on when credentials are used in NSURLSessionDownloadTask (From: Daryle Walker <email@hidden>)

  • Prev by Date: Re: Setting the NSURLDownload user agent
  • Next by Date: Authentication isn't reentrant?
  • Previous by thread: Re: Questions on when credentials are used in NSURLSessionDownloadTask
  • Next by thread: Re: Questions on when credentials are used in NSURLSessionDownloadTask
  • Index(es):
    • Date
    • Thread