cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Are you interested in hearing how one of our Community members uses Dropbox for sailing trips? Read all about it 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: 

migrating from API 1 to 2 - how do I know if I have OAuth 1 tokens?

migrating from API 1 to 2 - how do I know if I have OAuth 1 tokens?

Bob S.15
Collaborator | Level 9

I am finally getting around to updating my OLD apps from the original Dropbox IOS API to the new one. I'm looking at the migration guide, and the first thing it says is to check my OAuth tokens to see if they are version 1 or 2.  How do I know which I have? 

 

Also, the migration guide describes using the "endpoint" /oauth2/token_from_oauth1 to transition old tokens.  So, I am coming to this from an ancient time -- what is an "endpoint", and is this 'token_from_oauth1' a function that you call from Objective-C in an iOS app?  The documentation page I'm looking at only shows Python, Java, Ruby, and PHP examples, so maybe I'm not looking in the right place.

 

Is this where I should start?  Is there a guide for upgrading an iOS app somewhere?

 

Also is this page current?  It dates from March 2016,  but then also there is a v1 deprecation warning at the top of it:

https://www.dropbox.com/developers-v1/core/sdks/ios

 

Thanks,

Bob

 

54 Replies 54

Greg-DB
Dropbox Staff
Hi Bob, were you using an official API v1 Dropbox SDK, either the Core SDK or Sync SDK? If so, then yes, your app has OAuth 1 access tokens stored. (Both of those SDKs only used OAuth 1 access tokens.)

If you weren't using an official SDK, the easiest way to check is to see if your access tokens have two pieces (a key and secret) in which case they are OAuth 1 access tokens. If they're just one long string, they're OAuth 2 access tokens.

This old blog post has some helpful code for extracting those old access tokens:

https://blogs.dropbox.com/developers/2015/05/migrating-sync-sdk-access-tokens-to-core-sdk/

The API v2 equivalent of /1/oauth2/token_from_oauth1 is /2/auth/token/from_oauth1:

https://www.dropbox.com/developers/documentation/http/documentation#auth-token-from_oauth1

If you're using the API v2 Objective-C SDK, that's the -tokenFromOauth1:oauth1TokenSecret: method:

https://dropbox.github.io/dropbox-sdk-obj-c/api-docs/latest/Classes/DBAUTHRoutes.html#/c:objc(cs)DBA...:

Bob S.15
Collaborator | Level 9

Hey Greg,

 

 

My iOS project has a "DropboxSDK.framework" in it, which looks like it is from December 2014.  So it is probably OAuth1.

 

So, where do I find the API v2 Objective-C SDK?  Is that link at the end of my post the correct one?

 

Thanks

Bob

 

Greg-DB
Dropbox Staff
The DropboxSDK.framework is the iOS Core SDK, which uses API v1 and OAuth 1 access tokens.

You can find the API v2 Objective-C SDK here:

https://www.dropbox.com/developers/documentation/objective-c

Bob S.15
Collaborator | Level 9

OK thanks -- it says the minimum OS version is iOS 8.  Does that mean Dropbox support is going to end for iOS7 devices in June?  I'm still supporting older OS versions -- is there a way to use Dropbox API v2 and still do that?

Thanks

Bob

 

Greg-DB
Dropbox Staff

The API v2 Objective-C SDK itself supports iOS 8+. If you need to support older versions of iOS, you can either fork the SDK and make the necessary modifications for your use case, or call the HTTP interface for API v2 directly without using the SDK.

Bob S.15
Collaborator | Level 9

Hey Greg,

 

  When compiling with the new iOS API SDK, I get this XCode warning: 

ld: warning: ignoring file /Users/bob/Library/Developer/Xcode/DerivedData/Voxel-feiijazkmmkqehbmctcmaszabhor/Build/Products/Debug-iphoneos/ObjectiveDropboxOfficial.framework/ObjectiveDropboxOfficial, file was built for armv7 which is not the architecture being linked (arm64): /Users/bob/Library/Developer/Xcode/DerivedData/Voxel-feiijazkmmkqehbmctcmaszabhor/Build/Products/Debug-iphoneos/ObjectiveDropboxOfficial.framework/ObjectiveDropboxOfficial

 

Is there any way to get rid of that?

Thanks,

Bob

 

Greg-DB
Dropbox Staff
It sounds maybe like the architecture settings for your app and the pods don't match, or that you don't have arm64 listed in your build architectures. You can configure these in your project's "Build Settings", under "Architectures".

Bob S.15
Collaborator | Level 9

Okay thanks -- I looked at those and that stuff seems to match, but I have bigger problems for now.

 

Sorry for all the questions.  I'm coming to this after several years of not touching this Dropbox code.  I'm looking through my project for any reference to an OAuth token and not finding it.  It looks like I set up the connection to Dropbox this way: 

 

DBSession* dbSession = 

    [[[DBSession alloc]

      initWithAppKey:@"xxxxxxxxx"

      appSecret:@"xxxxxxxxx"

      root:kDBRootAppFolder] 

     autorelease];

 

    [DBSession setSharedSession:dbSession];

 

and then I use something called the 'restClient' to do all the interaction, like this:

 

restClient = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]];

[restClient createFolder:path];

[restClient uploadFile:filename toPath:toPath fromPath:pngPath];

 

 

Does that look familiar?  How would I go about moving to the new API from this?  

Greg-DB
Dropbox Staff

The SDK handles the access token retrieval and storage for you, so you wouldn't have had to deal with it manually before, but you'll need to extract them in order to hand them off to the new SDK.

 

As far as the client for the new SDK is concerned, I recommend working through the readme here, which shows how to configure the authorization flow, and get a client for making calls:

 

https://github.com/dropbox/dropbox-sdk-obj-c#configure-your-project

 

 

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Bob S.15 Collaborator | Level 9
What do Dropbox user levels mean?