• 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
NSURLConnection didReceiveAuthenticationChallenge weirdness
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSURLConnection didReceiveAuthenticationChallenge weirdness


  • Subject: NSURLConnection didReceiveAuthenticationChallenge weirdness
  • From: "Paul E. Robichaux" <email@hidden>
  • Date: Tue, 17 Jun 2008 20:04:12 -0400
  • Acceptlanguage: en-US
  • Thread-topic: NSURLConnection didReceiveAuthenticationChallenge weirdness

I'm trying to properly respond to authentication challenges by overriding didReceiveAuthenticationChallenge. In the init method of my custom object, I take the user name and password passed in and create a NSURLCredential:

                EWScreds = [NSURLCredential credentialWithUser: inUserName
                                           password: inPassword
                                        persistence:NSURLCredentialPersistenceForSession];

When I get an authentication challenge, I answer it with the stored credential:

-(void)connection:(MyURLConnection *)connection
        didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
    if ([challenge previousFailureCount] == 0)
    {
       [[challenge sender] useCredential:EWScreds    forAuthenticationChallenge:challenge];
    }
    else
        NSLog(@"Authentication failed on attempt %d", [challenge previousFailureCount]);
}

This fails 100% of the time, even though the user name and password are correct. If I create a new credential using literal strings for the user name and password, like below, the auth challenge succeeds.

      NSURLCredential *newCreds = nil;
        newCreds = [NSURLCredential credentialWithUser: @"email@hidden"
                                    password: @"AGreatPassword"
                                    persistence:NSURLCredentialPersistenceNone];
      [[challenge sender] useCredential:newCreds forAuthenticationChallenge: challenge];

I’ve verified that the password and user names match in both credentials (by using the user and password accessors on the credential objects). They appear to match. I’d appreciate any suggestions on what I might be doing wrong with this. Thanks in advance!

Cheers,
_Paul
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >NSDocument and default file names. (From: Godfrey van der Linden <email@hidden>)

  • Prev by Date: Re: Rethinking my approach; rather overwhelmed.
  • Next by Date: Re: objects aren't added to NSMutableArray
  • Previous by thread: Re: NSDocument and default file names.
  • Next by thread: Programatically placing panels inside a window
  • Index(es):
    • Date
    • Thread