简体   繁体   English

Dropbox SDK 401错误

[英]Dropbox SDK 401 Error

I am using the Dropbox SDK and I have it set up so the app can only access the /Apps/MyAPP folder. 我正在使用Dropbox SDK并将其设置为应用程序只能访问/ Apps / MyAPP文件夹。 I was testing it out and deleted the folder online. 我正在测试它并在线删除该文件夹。 Now when I'm in the app instead of asking to relink dropbox it gives me a 401 error. 现在,当我在应用程序而不是要求重新链接Dropbox时,它给我一个401错误。 I don't know why it doesn't display the view. 我不知道它为什么不显示视图。 It was working before I deleted the folder(unlinking the app online). 它在我删除文件夹之前工作(在线取消链接应用程序)。 Thank you in advance. 先感谢您。

PageFlipper[66893:c07] [WARNING] DropboxSDK: error making request to /1/metadata/sandbox - Token is invalid. PageFlipper [66893:c07] [警告] DropboxSDK:向/ 1 / metadata / sandbox发出错误请求 - 令牌无效。 2012-08-23 03:10:12.920 PageFlipper[66893:c07] Error loading metadata: Error Domain=dropbox.com Code=401 "The operation couldn't be completed. (dropbox.com error 401.)" UserInfo=0x23263fe0 {path=/, error=Token is invalid.} 2012-08-23 03:10:12.920 PageFlipper [66893:c07]加载元数据时出错:错误Domain = dropbox.com Code = 401“操作无法完成。(dropbox.com错误401.)”UserInfo = 0x23263fe0 {path = /,error =令牌无效。}

-(IBAction)addDropBox:(id)sender{
    if (![[DBSession sharedSession] isLinked]) {
        [[DBSession sharedSession] linkFromController:[self parentViewController]];
    }
    [[self restClient] loadMetadata:@"/"];
    restClient = nil;
};

I had the same problem. 我有同样的问题。 In my case the problem was that I did set the restClient before the user was connected. 在我的情况下,问题是我在连接用户之前设置了restClient。 In this case the userId is not set and the token is invalid. 在这种情况下,未设置userId且令牌无效。

My getter for restClient now looks like this: 我对restClient的getter现在看起来像这样:

- (DBRestClient *)restClient
{
    if (_restClient == nil) {
        if ( [[DBSession sharedSession].userIds count] ) {
            _restClient = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]];
            _restClient.delegate = self;
        }
    }

    return _restClient;
}

我通过将代码更改为以下内容来解决问题。

[[DBSession sharedSession] linkFromController:(UINavigationController *)[[appDelegate window] rootViewController]];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM