Reputation: 1892
I'm a little confused by this. I have this method.
-(BOOL)verifyAuth: (NSString*)username forPassword:(NSString*)password
{
NSURLSession *session = [NSURLSession sharedSession];
NSURLCredential *creds = [NSURLCredential credentialWithUser:username password:password persistence:NSURLCredentialPersistenceForSession];
[session dataTaskWithURL:MALAuthVerifyURL completionHandler:^(NSData *data, NSURLResponse *response, NSError *error)
{
NSLog(@"%@",data);
}];
return YES;
}
How do I pass the credentials to the NSURLSession object? Apple's docs say this:
"After you’ve created the NSURLCredential object:
For NSURLSession, pass the object to the authentication challenge’s sender using the provided completion handler block."
But i'm not sure what this actually means. I can't find any examples of this usage.
Thanks.
Upvotes: 1
Views: 4410
Reputation: 155
HTTP basic authentication (NSURLAuthenticationMethodHTTPBasic) requires a user name and password. Prompt the user for the necessary information and create an NSURLCredential object with credentialWithUser:password:persistence:.
After you’ve created the NSURLCredential object:
Maybe this helps.
Upvotes: 1
Reputation: 2525
You'll need to implement another delegate method, -URLSession:task:didReceiveChallenge:challenge:completionHandler:
.
Upvotes: 1