WWW-Authenticate 401 not calling NSURLConnectionDelegate
connection:didReceiveAuthenticationChallenge:
I am using AFNetworking's AFHTTPClient for my app's service calls. My
server uses HTTP digest authentication to authenticate. The service call
is returning a 401 HTTP error with WWW-Authenticate header in its response
as a challenge like this:
HTTP/1.1 401
WWW-Authenticate: Digest realm="user@myserver.com",
qop="auth",
nonce="059c37d0e654fdba9c606f35ce84741998"
Content-Type: text/html; charset=utf-8
The connection:didReceiveAuthenticationChallenge: method is never called
in AFURLConnectionOperation, which is the NSURLConnectionDelegate in this
situation and would then call my block set in
setAuthenticationChallengeBlock:. Instead, I just get the error: Error
Expected status code in (200-299), got 401 in my AFHTTPRequestOperation
failure block.
As far as I understand, these are the only required fields in the
WWW-Authenticate header for HTTP digest authentication. It's very similar
to the response in this example on Wikipedia. I don't have any actual body
of the response since I'm not displaying any HTML to the user anyway.
Should this matter? I'm not using the opaque field, but this should be
optional. I don't support the "auth-int" quality of protection. Other than
that, I don't return a Server or Date header. Are either of these
required?
What is it I'm doing wrong here?
No comments:
Post a Comment