简体   繁体   中英

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. 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. 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. 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.}

-(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. In this case the userId is not set and the token is invalid.

My getter for restClient now looks like this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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