I use the following code to make a GET request including a header Authorization but does not seem to work...the get request does not include the authorization token. Any ideas?
// 1 - define resource URL
NSURL *URL = [NSURL URLWithString:@"https://myurl"];
AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
AFHTTPRequestSerializer *requestSerializer = [AFHTTPRequestSerializer serializer];
[requestSerializer setValue:[NSString stringWithFormat:@"Bearer %@",Token] forHTTPHeaderField:@"Authorization"];
manager.requestSerializer = requestSerializer;
//3 - set a body
NSDictionary *body =@{@"email":@"[email protected]"};
//4 - create request
[manager GET:URL.absoluteString
parameters:body
progress:nil
//5 - response handling
success:^(NSURLSessionDataTask * _Nonnull task, NSDictionary *responseObject) {
NSLog(@"Reply POST JSON: %@", responseObject);
}
failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSLog(@"error on machine token: %@", error);
}
];