We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
Crypto C.
11 years agoNew member | Level 1
OAuth 2.0 - IOS API V 2.0
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.
16 Replies
Replies have been turned off for this discussion
- SGS E.11 years agoNew member | Level 1
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
- Crypto C.11 years agoNew member | Level 1
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
- Greg-DB11 years ago
Dropbox Community Moderator
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/
- SGS E.11 years agoNew member | Level 1
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)"
- Greg-DB11 years ago
Dropbox Community Moderator
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.
- SGS E.11 years agoNew member | Level 1
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 :(
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!