Can't find AFHTTPClient on AFNetworking 2.0, to use:
AFHTTPClient *client = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:@"http://examplewebsite.com]];
[client setAuthorizationHeaderWithUsername:@"username" password:@"password"];
How it needs to be manage on AFNetworking 2.0?
As @gimenete mentions multipart requests will fail when using @titaniumdecoy credential approach as this is applied in the challenge block and the current version of AFNetworking has an issue with this. Instead of using the credential approach you can embed the authentication in the NSMutableRequest header
Where you will need to use a third party BASE64 encoding library such as NSData+Base64.h and .m File from Matt Gallaghers pre ARC BASE64 solution
Here is an example of performing basic HTTP authentication with AFNetworking 2.0 using NSURLCredential. The advantage of this approach over using the AFHTTPRequestSerializer
setAuthorizationHeaderFieldWithUsername:password:
method is that you can automatically store the username and password in the keychain by changing thepersistence:
parameter of NSURLCredential. (See this answer.)AFNetworking 2.0 new architecture use serializers for creating requests and parsing responses. In order to set the authorization header, you should first initialize a request operation manager that replaces the AFHTTPClient, create a serializer and then call the dedicated method to set the header.
For example you code would become:
You should read the documentation and the migration guide to understand the new concepts that come with the version 2.0 of AFNetworking.