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 agoI'm not sure I follow. Can you share the full error/output you're getting?
Also, to clarify, you are entering the values in updateAccessToken:@"" accessTokenSecret:@"" forUserId:@"" and are just redacting them for the forum, correct?
You should, as the access token is sensitive, but I want to make sure you do have the right values there. The updateAccessToken parameter should be the OAuth 1 access token key, the accessTokenSecret parameter should be the OAuth 1 access token secret, and the forUserId should be your account's user ID.
Also, to clarify, you are entering the values in updateAccessToken:@"" accessTokenSecret:@"" forUserId:@"" and are just redacting them for the forum, correct?
You should, as the access token is sensitive, but I want to make sure you do have the right values there. The updateAccessToken parameter should be the OAuth 1 access token key, the accessTokenSecret parameter should be the OAuth 1 access token secret, and the forUserId should be your account's user ID.
katharina
9 years agoExplorer | Level 3
Yes, i am entering the access token.
My query is that how you like to use this access token in the below method and display folder ,
self.restClient = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]];
self.restClient.delegate = self;
My query is that how you like to use this access token in the below method and display folder ,
self.restClient = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]];
self.restClient.delegate = self;
- Greg-DB9 years ago
Dropbox Community Moderator
Once you've set the access token in the session, and retrieved a client with that session, as above, you can use that client to make calls.
The tutorial covers the basic of using a client to make calls. For example, to list a folder:
https://www.dropbox.com/developers-v1/core/start/ios#listing
What part specifically isn't working for you? - katharina9 years agoExplorer | Level 3HI greg,
Suppose i have access token like "dsfhakfhanflfjfba455".
So can you suggest me how i can login to the dropbox without redirecting to the Login controller of dropbox.
Plz help me with a proper code. I am stuck at this from past 2 weeks. - Greg-DB9 years ago
Dropbox Community Moderator
Can you share the code you have so far and post the error or unexpected output you're getting? If I see what's not working for you, I may be able to offer more help.
Also, is your access token just one piece like that? If so, you likely have an OAuth 2 access token. You indicated you're using the v1 iOS Core SDK, which uses OAuth 1 access tokens, but if you got the token elsewhere, it is likely an OAuth 2 access token. You'll need an OAuth 1 access token if you're using the iOS Core SDK.
If you are working with an OAuth 2 access token, I do recommend using the API v2 SDK instead, per my original message. (That's recommended anyway, as API v1 is deprecated.) - katharina9 years agoExplorer | Level 3Hi Greg,
MY token is similar to this y4yp61aez2fn8
--- hope so that now you can understand my query.
My query---- How i can authorise from different devices using the access token or DBSesssion. And once i authorise i want to fetch the data of dropbox. i need the coding solution for this. - katharina9 years agoExplorer | Level 3Yes, this is my query is that how we can set the access token in the session and how to retrieve the client. Once you help me to fix it after that i can easily fetch the data. Help me to find solution with code in objective c.
- Greg-DB9 years ago
Dropbox Community Moderator
It sounds like "y4yp61aez2fn8" is the key for an OAuth 1 access token. There should also be a corresponding secret value for the OAuth 1 access token. With those values, you can set the access token using the updateAccessToken method I mentioned ealier.
I don't have any pre-written code for this to share though, as this is not something we recommend you do, and that SDK is deprecated anyway.
That said, if you need help, please share the code you have so far and post the error or unexpected output you're getting. If I see what's not working for you, I may be able to offer more help.
- katharina9 years agoExplorer | Level 3
Yes, i have all access token, token sercert, user id, And i use this all in such way.
1. I create a method for the updateToken as below and in this method i am fetching the folder of dropbox.
2 I call this method to update token in viewDid Load
3 When i run the app, it did not display the folder of the dropbox and even do not that it is logged in the dropbox using updated access or not.- (void)viewDidLoad { [super viewDidLoad]; [self updateAccessToken:@"zu7k2w75btivr" accessTokenSecret:@"ndxj3c5u4kzp3" forUserId:@"653926434"]; } //update access token method - (void)updateAccessToken:(NSString *)token accessTokenSecret:(NSString *)secret forUserId:(NSString *)userId { [self.restClient loadMetadata:@"/"]; }
Error---[WARNING] DropboxSDK: error making request to /1/account/info - (400) invalid_request [WARNING] DropboxSDK: error making request to /1/metadata/dropbox - (400) invalid_request
- Greg-DB9 years ago
Dropbox Community Moderator
Thanks! That's helpful. It looks like you're defining your own updateAccessToken method. That's actually an existing method on DBSession though. You shouldn't define your own. You should call that on your DBSession instance before attempting API calls such as loadMetadata.
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!