【问题标题】:failed to fetch current user The operation couldn’t be completed. (NSURLErrorDomain error -1012failed to fetch current user 操作无法完成。 (NSURLErrorDomain 错误 -1012
【发布时间】:2015-04-17 17:00:30
【问题描述】:

我收到 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);
    }];
}

【问题讨论】:

    标签: ios xcode afnetworking


    【解决方案1】:

    我不确定这是否能回答您的问题,但我发现当调用 Web 服务时同步返回 401“未授权”错误,iOS 将简单返回一个模糊的 -1012 错误。

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多