iOS Dropbox SDK - Cannot upload or get metadata

雨燕双飞 提交于 2019-11-28 11:22:50

问题


This app used to work properly, but now I cannot upload a file or get metadata. Whenever I try to upload, I'll get

File upload failed with error: Error Domain=dropbox.com Code=401 "The operation couldn’t be completed. (dropbox.com error 401.)" 

But when trying to get metadata I'll get

Error loading metadata: Error Domain=dropbox.com Code=403 "The operation couldn’t be completed. (dropbox.com error 403.)" 

I've been trying to re-authenticate, but there seems to be no difference after I execute unlink command. I've tried placing this command in different places.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
//[[DBSession sharedSession] unlinkAll];
DBSession *dbSession = [[DBSession alloc]
                        initWithAppKey:@"**********" //AppKey
                        appSecret:@"************" //Secret
                        root:kDBRootDropbox]; // kDBRootAppFolder or kDBRootDropbox
[DBSession setSharedSession:dbSession];
[[DBSession sharedSession] unlinkAll];
return YES;
}

It also seems like it's not accessing the authentication flow method thing:

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url sourceApplication:(NSString *)source annotation:(id)annotation {
if ([[DBSession sharedSession] handleOpenURL:url]) {
    if ([[DBSession sharedSession] isLinked]) {
        NSLog(@"App linked successfully!");
        // At this point you can start making API calls
    }
    return YES;
}
// Add whatever other url handling code your app requires here
return NO;
}

I've been following the instructions in the Dropbox documentation and can't seem to find what's wrong.

EDIT: This is where I call linkFromController inside my ViewController

- (void)viewDidLoad
{
[super viewDidLoad];

self.restClient = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]];
self.restClient.delegate = self;

if (![[DBSession sharedSession] isLinked]) {
    [[DBSession sharedSession] linkFromController:self];
}

}

来源:https://stackoverflow.com/questions/23325875/ios-dropbox-sdk-cannot-upload-or-get-metadata

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!