views:

36

answers:

1

I've seen some similar questions here on SO, but none recent - so i'm checking in to see if anything's changed.

I see that didReceiveAuthenticationChallenge: is perfectly capable of doing a base64 encode for basic authentication, but the server i need to send a basic auth Authorization: header to doesn't return an HTTP401 and (I assume?) doesn't cause the didReceiveAuthenticationChallenge: delegate message to get sent - so I can't build the credential in there.

So instead, I'm using

[urlRequestForMyWorkspace addValue:@"Basic " forHTTPHeaderField:@"Authorization"];

before calling initWithRequest:

But - I can't find an objective-c api that works on the iphone to build that base64 encoded credential from a username and pw (other than writing one e.g. http://www.cocoadev.com/index.pl?BaseSixtyFour).

So - is that the only way, or is there some other way i can force the http basic auth credential to be sent using the standard apis - if the server isn't returning a 401, which is what i'm assuming causes didReceiveAuthnChallenge: to be sent?

thanks, Richard

A: 

Well the problem is on your server side code, since it is not returning 401 => didReceiveAuthenticationChallenge: delegate will never be called. So you are forced to do it this way (using header fields)

itsaboutcode