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...
Greg-DB
Dropbox Community Moderator
9 years agoAre 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.
- katharina9 years agoExplorer | Level 3May i use sdk API v2 on xcode 7.3 version. Also i need link to download the latest sdk for ios.
- katharina9 years agoExplorer | Level 3i 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- Greg-DB9 years ago
Dropbox Community Moderator
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.
- 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
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!