Reputation: 1221
I am using Core API for integrating dropbox with an iOS app. I am able to authenticate an account, and successfully upload files.
But say after authentication, user deletes the app folder from the dropbox account, or uninstalls the app through dropbox settings.
After that if I try to upload a file, the whole file gets uploaded (progress reaches from 0 to 1) and then I receive an error with error code -1021
which corresponds to NSURLErrorRequestBodyStreamExhausted
, and nor error code 401
according to Standard API errors in https://www.dropbox.com/developers/core/api.
The issue is that this is happening on devices with iOS 6, even the account is not unlinked by itself.
I have a device with iOS 5, which gets an error code of 401
(but that too after the whole file has been uploaded), which is authentication error (error code 401) as explained in core api docs. And the account gets unlinked by itself.
Update: This bug has been solved in the latest dropbox core api Build.
Upvotes: 2
Views: 1522
Reputation: 8121
The following code will immediately request the users Dropbox account information (if they are currently linked) when your app is launched. If the user deletes the apps folder, or revokes access to your app from Dropbox.com, then the user will be immediately unlinked when your app is launched. I think this is good practice regardless of if the SDK has a bug that fails to return 401 when uploading a file.
Add this to your app delegates didFinishLaunchingWithOptions
method where you initialize Dropbox
DBSession* dbSession = [[[DBSession alloc] initWithAppKey:DROPBOX_KEY appSecret:DROPBOX_SECRET root:kDBRootAppFolder] autorelease];
[DBSession setSharedSession:dbSession];
if ([[DBSession sharedSession] isLinked]) {
DBRestClient* dbRestClient = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]];
[dbRestClient setDelegate:self];
[dbRestClient loadAccountInfo];
}
Then add the following method to your app delegate
- (void)restClient:(DBRestClient*)client loadAccountInfoFailedWithError:(NSError*)error {
if (error.code == 401) {
[[DBSession sharedSession] unlinkAll];
}
}
Upvotes: 1