We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
katharina
9 years agoExplorer | Level 3
Re-authenticate using access token
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...
katharina
9 years agoExplorer | Level 3
i am using sdk 1.3 and api version is 1. And i write my whole in this. so i need a solution for this with coding part. I need it urgent.
Thanks
Thanks
Greg-DB
Dropbox Community Moderator
9 years agoIt 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.
- katharina9 years agoExplorer | Level 3
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
- Greg-DB9 years ago
Dropbox Community Moderator
Once you've set the access token, you can get a DBRestClient using DBRestClient.initWithSession. From there, you use the client normally:
https://www.dropbox.com/developers-v1/core/start/ios- katharina9 years agoExplorer | Level 3
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.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
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!