Take the 2-minute tour ×

I can do authentication with NSURL and user can assign username and password. However, I got another problem. If I open this, http://html5test.com/ , it also pop up and ask username and password. I got authentication even if it is not supposed to get. I would like to know how to do.

   connection_for_auto = [[NSURLConnection alloc] initWithRequest:request delegate:self];
         [connection_for_auto start];
        NSLog(@"Request >>  %@ and !firsttimeonly",request);
        return NO;
    self.lbl_error.hidden = YES; //hide error message label
    return YES;


- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge

    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Login"
                                          otherButtonTitles:@"OK",@"Auto", nil];

    alertView.transform=CGAffineTransformMakeScale(1.0, 0.75);
    alertView.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
    [alertView show];
share|improve this question
add comment

1 Answer

I think I have found a way to do. I need to check what kind of authentication method I use.

if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodHTTPBasic] || [challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodNTLM])
share|improve this answer
add comment

Your Answer


