Basic authentication with afnetworking 2

Use -[AFHTTPRequestSerializer setAuthorizationHeaderFieldWithUsername:password:] on -[AFHTTPSessionManager requestSerializer].

For example, in your AFHTTPSessionManager subclass:

@implementation MyHTTPSessionManager

- (instancetype)initWithBaseURL:(NSURL *)url {
    self = [super initWithBaseURL:url];
    if (self) {
        [self.requestSerializer setAuthorizationHeaderFieldWithUsername:@"username" password:@"password"];
    return self;


Follow me on Twitter to keep up with what I’ve learned building my personal finance tool, Stash.

Read more posts …
Written: September 27th, 2013
Categories: ios, objc, c, mac, afnetworking, authentication