无法获取当前用户无法完成操作。 (NSURLErrorDomain错误-1012

时间:2015-04-17 08:30:15

标签: ios xcode afnetworking

我收到NSURLErrorDomain错误-1012。 xcode 6.2中的错误,我能够成功获取访问令牌,我尝试重置模拟器..这里是代码

-(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(@"Quering accessToken failed %@", error);
        }];
    }                          cancel:^{
        NSLog(@"Authorization was cancelled by user");
    }                         failure:^(NSError *error) {
        NSLog(@"Authorization failed ::::%@", error.localizedDescription);
    }];
}

1 个答案:

答案 0 :(得分:0)

我不确定这是否会回答您的问题,但我发现当同时调用网络服务 时会返回401&#34 ;未经授权"错误,iOS只会返回一个模糊的-1012错误。

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

因此,请尝试检查您是否遇到身份验证问题,并从那里解决问题。