Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
Hello !
I use the the version API dropbox 1.0 for my app IOS, the new 2.0 is only swift and i can not use it because my app use only object-c.
So now i use API 1.0 for generate autentication DBSession restClient etc then use "https://api.dropboxapi.com/1/oauth2/token_from_oauth1" for access_token and call via HTTP the new api.dropboxapi.com/2.
This method works correctly, my question is, if this method is a good way to take advantage of the new API V2 ?
thanks
m.
ok,
add :
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
and now it's ok ....
good work.
Hi, Could you please give some instruction how to get acessToken v2 from accessToken v1?
i know this API "https://api.dropboxapi.com/1/oauth2/token_from_oauth1 but dont know how to pass the parameters.
i'm using ios sdk
Hi SGS E. none parameters is required, post
"https://api.dropboxapi.com/1/oauth2/token_from_oauth1" method "POST" with
Authorization OAuth 1.0 and return access_token OAuth 2.0
very easy.
bye
That's correct, that endpoint requires OAuth 1 signing. This blog post, specifically step 4, may be helpful:
https://blogs.dropbox.com/developers/2012/07/using-oauth-1-0-with-the-plaintext-signature-method/
Hi,
I'm sorry but i still cant do it.
Now what i have is DBSession restClien or something like that.Is there anyway to get accesssToken v2 from resclient ?
Could you please give some sample code in your project ?
here is my code but it doesnt work well
MPOAuthCredentialConcreteStore* credential = [[DBSession sharedSession] credentialStoreForUserId:[info userId]];
AFHTTPSessionManager* manager = [[AFHTTPSessionManager alloc] initWithBaseURL:[NSURL URLWithString:BASE_URL]];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
manager.requestSerializer = [AFHTTPRequestSerializer serializer];
[manager.requestSerializer setValue:@"OAuth" forHTTPHeaderField:@"Authorization"];
[manager.requestSerializer setValue:@"1.0" forHTTPHeaderField:@"oauth_version"];
[manager.requestSerializer setValue:@"PLAINTEXT" forHTTPHeaderField:@"oauth_signature_method"];
[manager.requestSerializer setValue:APP_KEY_DB forHTTPHeaderField:@"oauth_consumer_key"];
[manager.requestSerializer setValue:credential.accessToken forHTTPHeaderField:@"oauth_token"];
[manager.requestSerializer setValue:[NSString stringWithFormat:@"%@&%@",credential.requestTokenSecret,credential.accessTokenSecret] forHTTPHeaderField:@"oauth_signature"];
[manager POST:@"https://api.dropboxapi.com/1/oauth2/token_from_oauth1" parameters:@{} success:^(NSURLSessionDataTask *task, id responseObject) {
} failure:^(NSURLSessionDataTask *task, NSError *error) {
}];
//It show error
Code=-1011 "Request failed: bad request (400)"
I don't believe we have any sample code for this specifically in Objective-C unfortunately.
Looking at your code, it seems you are setting all of the OAuth parameters as individual parameters, when they should just be together in the one "Authorization" header, as shown in the blog post I linked to.
yah, you are right , after change the OAuth parameters as the one it works like a charm !
Thank you very much.
btw,dropbox sdk is great but the ios' sdk and its document is quite out of date ![]()
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!