Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
thedeck
9 years agoHelpful | Level 6
OAuth2 token with iOS SDK
Hello,
I'm currently migrating one of my iOS app to the V2 of the API.
When a user authorize my app to use its Dropbox account I want to retrieve the OAuth2 token to share it with my server to allow long running backgroud processes.
This worked fine with the V1 of the API and still works fine in V2 when the authorization is made from a browser or a web view as the token is in the url returned by the SDK.
However, when the auth is done by the Dropbox iOS app, the url returned in to the
-application: openURL: options:
method is different and provides an oauth_token_secret parameter but no access_token.
How can I get the oauth2 token from the SDK knowing that the DBOAuthResult returns the same oauth_token_secret for its accessToken property in this case ? and not a valid oauth2 token.
Alternatively, is it possible to forbid the auth flow to use the installed Dropbox iOS app ?
Thanks !
Hi, it sounds like you're using the official API v2 Objective-C SDK. Is that correct? If so, the SDK handles the access token retrieval and storage for you, regardless of which flow exactly was used (e.g., via app or web). If you're using that SDK, you should just implement the authorization flow as documented here.
That will automatically store the token, and you can then retrieve the client via DBClientsManager authorizedClient. That is, you don't need to check the URL parameters yourself.
If you then do want to retrieve the access token(s) themselves, you can use DBOAuthManager.getAccessToken or DBOAuthManager.getAllAccessTokens.
Thanks, that works perfectly!
2 Replies
Replies have been turned off for this discussion
- Greg-DB9 years ago
Dropbox Community Moderator
Hi, it sounds like you're using the official API v2 Objective-C SDK. Is that correct? If so, the SDK handles the access token retrieval and storage for you, regardless of which flow exactly was used (e.g., via app or web). If you're using that SDK, you should just implement the authorization flow as documented here.
That will automatically store the token, and you can then retrieve the client via DBClientsManager authorizedClient. That is, you don't need to check the URL parameters yourself.
If you then do want to retrieve the access token(s) themselves, you can use DBOAuthManager.getAccessToken or DBOAuthManager.getAllAccessTokens.
- thedeck9 years agoHelpful | Level 6
Thanks, that works perfectly!
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!