gpt4 book ai didi

ios - 将iOS项目与Box SDK集成时出现问题

转载 作者:行者123 更新时间:2023-11-29 13:04:46 26 4
gpt4 key购买 nike

我在将Box iOS SDK与我的项目集成的说明方面遇到问题。我已按照https://github.com/box/box-ios-sdk-v2上的说明进行操作,并且已获取我的应用程序以成功进行身份验证。现在,我停留在第一部分的“进行API调用”部分(获取文件夹的子级)。我的基本应用程序现在基本上只有两个按钮:(1)链接; (2)生孩子。链接后,它要求登录box.com。我做;然后返回到空白屏幕。然后,我必须再次运行该程序,然后单击“获取子项”。我试图查看此链接(iOS Box SDK BoxFolder.children always nil)和其他问题以找到解决方案,但未能成功。以下是每个程序的例程:

- (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:]:将POST api.box.com/oauth2/token列在全局队列中
2013-09-16 17:18:45.585 BoxIntegratedApp-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]:启动POST 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 POST api.box.com/oauth2/token完成了finsh加载
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

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

2013-09-16 17:25:43.937 BoxIntegratedApp-Without_Addition_of_Sample_Files [794:11303]-[BoxParallelAPIQueueManager enqueueOperation:]:将GET api.box.com/2.0/folders/0/items列在全局队列中
2013-09-16 17:25:43.939 BoxIntegratedApp-Without_Addition_of_Sample_Files [794:15407] + [BoxAPIOperation globalAPIOperationNetworkThreadEntryPoint:]:{name = Box API Operation Thread,num = 3}已启动
2013-09-16 17:25:46.173 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:46.180 BoxIntegratedApp-Without_Addition_of_Sample_Files [794:15407]-[BoxAPIOperation executeOperation]:启动GET api.box.com/2.0/folders/0/items
2013-09-16 17:25:46.670 BoxIntegratedApp-Without_Addition_of_Sample_Files [794:15407]-[BoxAPIAuthenticatedOperation连接:didReceiveResponse:]:OAuth2访问 token 已过期。
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_Sample_Files [794:15407]-[BoxParallelAPIQueueManager enqueueOperation:]:将GET api.box.com/2.0/folders/0/items列在全局队列中
2013-09-16 17:25:46.671 BoxIntegratedApp-Without_Addition_of_Sample_Files [794:15407]-[BoxAPIAuthenticatedOperation连接:didReceiveResponse:]:尝试自动OAuth2 token 刷新
2013-09-16 17:25:46.671 BoxIntegratedApp-Without_Addition_of_Sample_Files [794:15407]-[BoxParallelOAuth2Session performRefreshTokenGrant:]:访问 token 已过期:(空)
2013-09-16 17:25:46.671 BoxIntegratedApp-Without_Addition_of_Sample_Files [794:15407]-[BoxParallelOAuth2Session performRefreshTokenGrant:]:正在刷新 token
2013-09-16 17:25:46.672 BoxIntegratedApp-Without_Addition_of_Sample_Files [794:15407]-[BoxParallelAPIQueueManager enqueueOperation:]:将POST api.box.com/oauth2/token列在全局队列中
2013-09-16 17:25:46.673 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:46.677 BoxIntegratedApp-Without_Addition_of_Sample_Files [794:11303]儿童错误,错误=错误Domain = com.box.sdk.errordomain代码= 20000“操作无法完成。(com.box。 sdk.errordomain错误20000。)“
2013-09-16 17:25:46.677 BoxIntegratedApp-Without_Addition_of_Sample_Files [794:15407]-[BoxAPIOperation完成]:BoxAPIOperation GET api.box.com/2.0/folders/0/items状态为3
2013-09-16 17:25:46.679 BoxIntegratedApp-Without_Addition_of_Sample_Files [794:15407]-[BoxAPIOperation executeOperation]:BoxAPIOperation POST api.box.com/oauth2/token已启动
2013-09-16 17:25:46.679 BoxIntegratedApp-Without_Addition_of_Sample_Files [794:15407]-[BoxAPIOperation executeOperation]:启动POST api.box.com/oauth2/token
2013-09-16 17:25:47.039 BoxIntegratedApp-Without_Addition_of_Sample_Files [794:15407]-[BoxAPIOperation connectionDidFinishLoading:]:BoxAPIOperation POST api.box.com/oauth2/token完成了finsh加载
2013-09-16 17:25:47.040 BoxIntegratedApp-Without_Addition_of_Sample_Files [794:15407]-[BoxAPIQueueManager OAuth2OperationDidComplete:]:POST api.box.com/oauth2/token已完成。从OAuth2依赖项集中删除
2013-09-16 17:25:47.041 BoxIntegratedApp-Without_Addition_of_Sample_Files [794:15407]-[BoxAPIOperation完成]: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.281 BoxIntegratedApp-Without_Addition_of_Sample_Files [794:11303]儿童错误,错误=错误Domain = com.box.sdk.errordomain代码= 20002“操作无法完成。(com.box。 sdk.errordomain错误20002。)“

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中有文件。如果有人可以帮助我,我将非常感激。我一直在尝试明确地遵循说明。或者,如果您需要更多信息来诊断此问题,请告诉我。非常感谢你。

维诺德

最佳答案

您的错误代码是20002,代表此状态

访问 token 已过期,并且该操作无法重新排队,因为该操作 token 之前已被重新排队。

这是从Box API GIT文档获得的,因此在执行此操作时,应确保访问 token 有效。

另外,看看文件夹选择器,您应该执行以下操作:

   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];
}

关于ios - 将iOS项目与Box SDK集成时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18907522/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com