cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox 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
Go to solution

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

Greg-DB
Dropbox Staff
Go to solution

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

thedeck
Helpful | Level 6
Go to solution

Thanks, that works perfectly!

View solution in original post

2 Replies 2

Greg-DB
Dropbox Staff
Go to solution

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.

thedeck
Helpful | Level 6
Go to solution

Thanks, that works perfectly!

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    thedeck Helpful | Level 6
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?