Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
Hi, i get access token in my app using dropbox api. i want to reauthenticate in the same app on other device using these access token. How i can program it in objective c. Kinldy provide me solutions for this as i need it very badly.
Looking for needfull help.
regards
Are you using the official API v2 Objective-C SDK?
If so, you can construct a DBUserClient on the fly using an existing access token using the DBUserClient.initWithAccessToken constructor. If you want to have the SDK store the access token for you, you can use DBOAuthManager.storeAccessToken.
Note that access tokens are sensitive, as they enable access to the account, so make sure you transport the access token securely. That being the case, it may just be easier/safer to process the app authorization flow again on the other device. Also, note that it isn't reccomended to distribute an app with an access token for a particular account embedded in the app, as that can be extracted by a malicious user.
It sounds like you're using the iOS Core SDK, for Dropbox API v1. Dropbox API v1 is deprecated and being retired in a few months.
You should migrate to API v2 whenever you can. I recommend using the official API v2 Objective-C SDK.
This is technically possible with the iOS Core SDK as well though. You can store an existing access token using DBSession.updateAccessToken:
- (void)updateAccessToken:(NSString *)token accessTokenSecret:(NSString *)secret forUserId:(NSString *)userId;
You can then init a DBRestClient for that user normally.
Yes, i user the same method for reauthenticate, but i do not know what i need to call once it is autheticate from this method to fetch dropbox folder. My code is bellow
v1AccessToken i am storing in the sever and accessing when i start my app.
if(v1AccessToken.length>0) { // [[DBSession sharedSession] updateAccessToken:v1AccessToken accessTokenSecret:v1AccessTokenSecret forUserId:ui]; [[DBSession sharedSession] updateAccessToken:@"" accessTokenSecret:@"" forUserId:@""]; if([DBSession sharedSession] != nil) { NSLog(@"Reauthenticating"); [self performSelector:@selector(fetchAllDropboxData) withObject:nil afterDelay:0.2]; }
how i can fetch the folder once it is authenticate usign this method. KInldy help me with coding part.
Regards
Hi Greg, I am using it in this way. But after all that it shows me that it session is expired and do you want to relink it.
if (![[DBSession sharedSession] isLinked]) { [[DBSession sharedSession] updateAccessToken:@"" accessTokenSecret:@"" forUserId:@""]; self.restClient = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]]; self.restClient.delegate = self; NSLog(@"Reauthenticating"); [self performSelector:@selector(fetchAllDropboxData) withObject:nil afterDelay:0.2]; // [[DBSession sharedSession] linkFromController:self]; { YourClientsViewController *control = [self.storyboard instantiateViewControllerWithIdentifier:@"YourClientsViewController"]; [self.navigationController pushViewController:control animated:YES]; } else { [[DBSession sharedSession] linkFromController:self]; UIAlertView *view = [[UIAlertView alloc]initWithTitle:@"Account Login!" message:@"Your dropbox account has been login" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; [view show]; if (!loadData) { loadData = @""; } // [MBProgressHUD showHUDAddedTo:self.view animated:YES]; [self performSelector:@selector(fetchAllDropboxData) withObject:nil afterDelay:0.2]; }
Can you please help me to modify this code so that it will work.
Hi there!
If you need more help you can view your support options (expected response time for a ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!