I need to connect to some server using https protocol. I will have to authenticate in order to get data, here's how I try to do this:
then in the delegate object I implement following methods:
The problem is that I never get authentication challenges, even though when I try to enter the same url via native Safari browser everything seems to work just fine. Moreover, received response shows error code 403, so forbidden. What am I doing wrong?
Code:
NSURLRequest *req = [NSURLRequest requestWithURL:[NSURL URLWithString:@"some server address"]];
NSURLConnection *manualConnection = [[NSURLConnection alloc] initWithRequest:req delegate:self startImmediately:YES];
Code:
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
NSLog(@"Logging response");
NSLog(@"Status code = %i",[((NSHTTPURLResponse*)response) statusCode]);
}
Code:
-(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
NSLog(@"Connection did receive authentification challenge");
}
The problem is that I never get authentication challenges, even though when I try to enter the same url via native Safari browser everything seems to work just fine. Moreover, received response shows error code 403, so forbidden. What am I doing wrong?