OSX Dropbox Sync API Error - unable to verify link request

前端 未结 2 1927
夕颜
夕颜 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

提交回复
热议问题