2

I'm getting NSURLErrorDomain error -1012. error in xcode 6.2 , I'm able to get the access token successfully, I tried reseting simulator.. here is the code

-(void)getLinkedInData:(LIALinkedInHttpClient*)client
{
    [client getAuthorizationCode:^(NSString *code) {
        [client getAccessToken:code success:^(NSDictionary *accessTokenData) {
            NSLog(@"Access token data: %@",accessTokenData);
            NSString *accessToken = [accessTokenData objectForKey:@"access_token"];
               NSLog(@"Access token: %@",accessToken);
            [client GET:[NSString stringWithFormat:@"https://api.linkedin.com/v1/people/~?oauth2_access_token=%@&format=json", accessToken] parameters:nil success:^(AFHTTPRequestOperation *operation, NSDictionary *result) {
                NSLog(@"current user %@", result);
            }            failure:^(AFHTTPRequestOperation *operation, NSError *error) {
                NSLog(@"failed to fetch current user %@", error.localizedDescription);
            }];
        }                   failure:^(NSError *error) {
            NSLog(@"Querying accessToken failed %@", error);
        }];
    }                          cancel:^{
        NSLog(@"Authorization was cancelled by user");
    }                         failure:^(NSError *error) {
        NSLog(@"Authorization failed ::::%@", error.localizedDescription);
    }];
}
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
codeIgnitor
  • 765
  • 1
  • 5
  • 16

1 Answers1

0

I'm not sure if this'll answer your question, but I've found that when a calling a web service synchronously, which returns a 401 "Not authorised" error, iOS will simply return a vague -1012 error.

iOS: How can i receive HTTP 401 instead of -1012 NSURLErrorUserCancelledAuthentication

So, try to check whether you're having authentication problems, and tackle the problem from there.

Community
  • 1
  • 1
Mike Gledhill
  • 27,846
  • 7
  • 149
  • 159