IOS Dropbox SDK - unable to download or retrieve metadata

This application is working correctly, but now I can’t upload the file or get metadata. Whenever I try to download, I will get

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

But when I try to get metadata, I get

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

I am trying to re-authenticate, but there seems to be no difference after executing the unlink command. I tried to place 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 that it does not access the authentication thread stream method:

- (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 follow the instructions in the Dropbox documentation and cannot find what is wrong.

EDIT: here 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];
}

}
+1
source share

Source: https://habr.com/ru/post/1538030/


All Articles