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];
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…