cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Back again with another edition of 'How we use Dropbox', so find out how Emma uses to-do lists to get it all done here!

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

OAuth2 token with iOS SDK

OAuth2 token with iOS SDK

thedeck
Helpful | Level 6

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 !

2 Accepted Solutions

Accepted Solutions

Re: OAuth2 token with iOS SDK

Greg-DB
Dropboxer

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.

View solution in original post

Re: OAuth2 token with iOS SDK

thedeck
Helpful | Level 6

Thanks, that works perfectly!

View solution in original post

2 Replies 2

Re: OAuth2 token with iOS SDK

Greg-DB
Dropboxer

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.

View solution in original post

Re: OAuth2 token with iOS SDK

thedeck
Helpful | Level 6

Thanks, that works perfectly!

View solution in original post

Poll
We love to learn from the educators who use Dropbox. Whether you teach kids, teens, adults or a combination of all three, we want to know what apps and integrations you use with Dropbox to help with teaching. Which of the ones below is your favorite, or most used tool?
Who's talking

Top contributors to this post

  • User avatar
    thedeck Helpful | Level 6
  • User avatar
    Greg-DB Dropboxer
What do Dropbox user levels mean?
Need more support?