OSX Dropbox Sync API Error - unable to verify link request

前端 未结 2 1896
夕颜
夕颜 2020-12-22 07:46

Coded in Swift I implemented after the Tutorial.

DBAccountManager is setup in AppDelegate on applicationDidFinishLaunching.

Later, when the user activates dr

相关标签:
2条回答
  • 2020-12-22 08:27

    I have same issue [ERROR] unable to verify link request after long research and studying the DropBoxSDK I come to the point that this error occurs when state ID is different from value saved at key KDBKLinkNonce. Every time at new Session it generates new state ID. See below code of [[DBSession sharedSession] handleOpenURL:url] method.

    - (BOOL)handleOpenURL:(NSURL *)url {
    NSString *expected = [NSString stringWithFormat:@"%@://%@/", [self appScheme], kDBDropboxAPIVersion];
    if (![[url absoluteString] hasPrefix:expected]) {
        return NO;
    }
    
    NSArray *components = [[url path] pathComponents];
    NSString *methodName = [components count] > 1 ? [components objectAtIndex:1] : nil;
    
    if ([methodName isEqual:@"connect"]) {
        NSDictionary *params = [DBSession parseURLParams:[url query]];
        NSString *token = [params objectForKey:@"oauth_token"];
        NSString *secret = [params objectForKey:@"oauth_token_secret"];
        NSString *userId = [params objectForKey:@"uid"];
    
        NSString *state = [params objectForKey:@"state"];
        NSString *nonce = [[NSUserDefaults standardUserDefaults] objectForKey:kDBLinkNonce];
        [[NSUserDefaults standardUserDefaults] removeObjectForKey:kDBLinkNonce];
        [[NSUserDefaults standardUserDefaults] synchronize];
        if (![nonce isEqual:state]) {
            DBLogError(@"unable to verify link request");
            return NO;
        }
    
        [self updateAccessToken:token accessTokenSecret:secret forUserId:userId];
    } else if ([methodName isEqual:@"cancel"]) {
        DBLogInfo(@"DropboxSDK: user cancelled Dropbox link");
    }
    
    return YES; }
    

    For further reference please check this link dropbox-sdk-ios

    0 讨论(0)
  • 2020-12-22 08:27

    I found something and since I found a fix for that, even the dropbox error is gone.

    The problem seems to be, that NSUserDefaults did not store any data (not in memory and not on disk!). Since Dropbox uses NSUserDefaults to check the state before and after, this killed the whole process. With getting the NSUserDefaults back working it seems the whole dropbox problem was gone. OSX NSUserDefaults not Working

    0 讨论(0)
提交回复
热议问题