I am developing an iOS application that makes frequent requests to the web server and I use AFNetworking (which I really like). However, I ran into an authorization problem that I simply cannot solve.
The server requires me to provide an authorization header in order to get the response I want. In particular, authorization headers should be:
Authorization = "ApiKey some-user-name:someNumericalApiKey"
I use AFNetworking throughout the project and everything works fine except for this authorization issue. I am using the following code:
[myClient setDefaultHeader:@"Authorization" value:@"ApiKey some-user-name:someNumericalApiKey"];
where myClient indicates an AFHTTPClient object. Oddly enough, when I register a request in AFHTTPRequestOperationLogger using AFHTTPRequestOperationLogger , the registrar claims that I have the correct headers set. However, the authorization header does not seem to reach the server - I do not see it in the server log.
To isolate the problem, I tried to make the same request using the good old NSURLRequest , as well as curl and requests libraries in Python - all this works fine, that is, the authorization header is sent and received (i.e. I can see it in the server log ), and the server response is what it should be.
If someone ran into the same problem (and found a solution), I would be very grateful for you.
Thanks.
marcel salathe
source share