1

我在将 Box iOS SDK 与我的项目集成时遇到问题。我已按照https://github.com/box/box-ios-sdk-v2上的说明进行操作,并且我的应用已成功通过身份验证。现在,我被困在第一部分的制作 API 调用部分(获取文件夹的子项)。我的骨架应用程序现在基本上只有两个按钮:(1)链接;(2) 生孩子。链接后,它要求登录box.com;我愿意; 然后它回到一个空屏幕。然后,我必须再次运行程序,然后点击 get children。我试图查看此链接(iOS Box SDK BoxFolder.children 始终为零)和其他问题以找到解决方案,但未能。以下是每个人的例程:

- (IBAction)linkAction:(id)sender {

    UIViewController *authorizationController = [[BoxAuthorizationViewController alloc] initWithAuthorizationURL:[[BoxSDK sharedSDK].OAuth2Session authorizeURL] redirectURI:nil]; 
    [self presentViewController:authorizationController animated:YES completion:nil]; 
}

- (IBAction)getChildrenAction:(id)sender { 

    BoxCollectionBlock success = ^(BoxCollection *collection) 
    { 
        dispatch_sync(dispatch_get_main_queue(), ^{ 
            NSLog(@"CHILDREN SUCCESS!!!"); 
        }); 
    }; 

    BoxAPIJSONFailureBlock failure = ^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSDictionary *JSONDictionary)
    {

        dispatch_sync(dispatch_get_main_queue(), ^{ 
            // handle errors 
            NSLog(@"CHILDREN ERROR, error = %@", error); 
        }); 
    }; 

    NSString *folderID = BoxAPIFolderIDRoot; 

    [[BoxSDK sharedSDK].foldersManager folderItemsWithID:folderID requestBuilder:nil success:success failure:failure]; 

}

这是链接后的成功输出:

2013-09-16 17:18:45.585 BoxIntegratedApp-Without_Addition_of_Sample_Files[760:11303]-[BoxParallelAPIQueueManager enqueueOperation:]:在全局队列 2013-09-16 17:18:45.585 BoxIntegratedApp 上排队 POST api.box.com/oauth2/token -Without_Addition_of_Sample_Files[760:11303] 已链接!!2013-09-16 17:18:45.587 BoxIntegratedApp-Without_Addition_of_Sample_Files[760:1730f] +[BoxAPIOperation globalAPIOperationNetworkThreadEntryPoint:]: {name = Box API Operation Thread, num = 4} 开始于 2013-09-16 17:18:45.587 BoxIntegratedApp- without_Addition_of_Sample_Files[760:1730f] -[BoxAPIOperation executeOperation]:BoxAPIOperation POST api.box.com/oauth2/token 已于 2013-09-16 17:18:45.588 BoxIntegratedApp-Without_Addition_of_Sample_Files[760:1730f] -[BoxAPIOperation executeOperation] 开始发布 api.box.com/oauth2/token 2013-09-16 17:18:45。596 BoxIntegratedApp-Without_Addition_of_Sample_Files[760:11303]-[BoxAuthorizationViewController webViewDidFinishLoad:] 2013-09-16 17:18:46.186 BoxIntegratedApp-Without_Addition_of_Sample_Files[760:1730f]-[BoxAPIOperation connectionDidFinishLoading:]:BoxAPIOperation.com令牌确实完成加载 2013-09-16 17:18:46.187 BoxIntegratedApp-Without_Addition_of_Sample_Files[760:1730f] -[BoxAPIQueueManager OAuth2OperationDidComplete:]: POST api.box.com/oauth2/token 已完成。从一组 OAuth2 依赖项中删除 com/oauth2/token 完成加载 2013-09-16 17:18:46.187 BoxIntegratedApp-Without_Addition_of_Sample_Files[760:1730f] -[BoxAPIQueueManager OAuth2OperationDidComplete:]: POST api.box.com/oauth2/token 已完成。从一组 OAuth2 依赖项中删除 com/oauth2/token 完成加载 2013-09-16 17:18:46.187 BoxIntegratedApp-Without_Addition_of_Sample_Files[760:1730f] -[BoxAPIQueueManager OAuth2OperationDidComplete:]: POST api.box.com/oauth2/token 已完成。从一组 OAuth2 依赖项中删除

2013-09-16 17:18:46.188 BoxIntegratedApp-Without_Addition_of_Sample_Files[760:1730f]-[BoxAPIOperation 完成]:BoxAPIOperation POST api.box.com/oauth2/token 以状态 3 完成

这是尝试生孩子后的失败输出:

15407] -[BoxAPIAuthenticatedOperation 连接:didReceiveResponse:]:OAuth2 访问令牌已过期。2013-09-16 17:25:46.670 BoxIntegratedApp-Without_Addition_of_Sample_Files[794:15407]-[BoxAPIAuthenticatedOperation 连接:didReceiveResponse:]:重新入队操作未能通过身份验证 2013-09-16 17:25:46.671 BoxIntegratedApp-Without_Addition_of_SampleFile_ :15407]-[BoxParallelAPIQueueManager enqueueOperation:]:在全局队列 2013-09-16 17:25:46.671 BoxIntegratedApp-Without_Addition_of_Sample_Files[794:15407]-[BoxAPIAuthenticatedOperation 连接上排队获取 api.box.com/2.0/folders/0/items :didReceiveResponse:]: 尝试自动 OAuth2 令牌刷新 2013-09-16 17:25:46.671 BoxIntegratedApp-Without_Addition_of_Sample_Files[794:15407] -[BoxParallelOAuth2Session performRefreshTokenGrant:]: 访问令牌过期:box.com/oauth2/token 完成。从 OAuth2 依赖项集中删除 2013-09-16 17:25:47.041 BoxIntegratedApp-Without_Addition_of_Sample_Files[794:15407] -[BoxAPIOperation finish]:BoxAPIOperation POST api.box.com/oauth2/token 以状态 3 完成 2013-09-16 17:25:47.047 BoxIntegratedApp-Without_Addition_of_Sample_Files[794:15407] -[BoxAPIOperation executeOperation]: BoxAPIOperation GET api.box.com/2.0/folders/0/items 已于 2013-09-16 17:25:47.048 BoxIntegratedApp-Without_Addition_of_Sample_Files [ 794:15407]-[BoxAPIOperation executeOperation]:开始 GET api.box.com/2.0/folders/0/items 2013-09-16 17:25:47.281 BoxIntegratedApp-Without_Addition_of_Sample_Files[794:15407]-[BoxAPIOperation connectionDidFinishLoading:]: BoxAPIOperation GET api.box.com/2.0/folders/0/items 完成加载 2013-09-16 17:25:47。

2013-09-16 17:25:47.282 BoxIntegratedApp-Without_Addition_of_Sample_Files[794:15407] -[BoxAPIOperation 完成]:BoxAPIOperation GET api.box.com/2.0/folders/0/items 完成状态 3

我在 box.com 的基本目录中有文件。如果有人能帮助我解决这个问题,我将不胜感激。我一直在尝试明确地遵循说明。或者,如果您需要更多信息来诊断此问题,请告诉我。非常感谢。

维诺德

4

1 回答 1

1

你的错误代码是 20002 代表这个状态

访问令牌已过期并且操作无法重新入队,因为它之前已经重新入队。

这来自 box API GIT 文档,因此您在执行此操作时应确保您的访问令牌有效。

另外,看看文件夹选择器你应该做这样的事情:

   if ([BoxSDK sharedSDK].OAuth2Session.isAuthorized)
{
    // in order to avoid a short lag, jump immediatly to the file picker if we are already authorized
    [self presentBoxFolderPicker];
}
else
{
    BoxFolderBlock success = ^(BoxFolder * folder) {
        [self presentBoxFolderPicker];
    };
    BoxAPIJSONFailureBlock failure = ^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSDictionary *JSONDictionary){
        [self boxError:error];
    };
    // try sending a hearbeat
    [[BoxSDK sharedSDK].foldersManager folderInfoWithID:BoxAPIFolderIDRoot
                                         requestBuilder:nil
                                                success:success
                                                failure:failure];
}
于 2013-10-02T08:11:08.057 回答