0
How can I do a basic HTTP authentication using Afnetworking in Objective - C ?
0
How can I do a basic HTTP authentication using Afnetworking in Objective - C ?
0
As well as other publications found here, the request is very similar. You will only need to add in requestSerializer
authentication data using the method setAuthorizationHeaderFieldWithUsername
.
In general, it looks something like this:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.requestSerializer = [AFHTTPRequestSerializer serializer];
[manager.requestSerializer setAuthorizationHeaderFieldWithUsername:@"usuario" password:@"senha"];
[manager GET:@"http://..." parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSString *response = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
NSLog(@"%@", response);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
Browser other questions tagged ios objective-c iphone afnetworking
You are not signed in. Login or sign up in order to post.
Obrigado Paulo.
– Alexandre