cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to make sure we keep you updated on the ideas that other users have shared here on the Community? Us too! Check them out over 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: 
1
Ask
2
Comments

DropboxClientsManager authorizeFromController not doing anything

Re: DropboxClientsManager authorizeFromController not doing anything

Greg-DB
Dropboxer
Oh, apologies, I didn't realize the second part was still Carthage output. Yes, in that case, please try removing the entire Carthage build of the SDK in that app and re-installing it.

Re: DropboxClientsManager authorizeFromController not doing anything

Bob S.15
Collaborator | Level 8

Okay.  The Example app works fine.  

 

I deleted the sdk's from my apps and re-downloaded.  They update fine now.

 

I read the release notes, though -- you dropped support for iOS 8?  So iOS9+ only?  Too soon!  I'm only just now dropping 7.

I set my cartfile to 3.0.11 which looks to be the one before you dropped iOS 8 support.   Should that work, or have I got to drop 8 to continue using Dropbox?

 

But my god there are sure a lot of changes since I was working on this just a couple of months ago.   

 

Here's one error I see a few times:  "instance method -progress not found".   This is in case like this one, where I was downloading a file:

 

    [[[[DBClientsManager authorizedClient].filesRoutes downloadUrl:remotePath overwrite:NO destination: destURL]
      setResponseBlock:^(DBFILESFileMetadata *result,  DBFILESDownloadError *downloaderror, DBRequestError *error, NSURL *destination) {
          if (result) {
              NSLog(@"%@\n", result);
              [brainpan loadedDropboxFile];
              
          } else {
              [brainpan loadDropboxFileFailed:(int)downloaderror.tag];
          }
      }] progress:^(int64_t bytesUploaded, int64_t totalBytesUploaded, int64_t totalBytesExpectedToUploaded) {
          NSLog(@"\n%lld\n%lld\n%lld\n", bytesUploaded, totalBytesUploaded, totalBytesExpectedToUploaded);
      }];

If I look at the API documentation, the example for downloading a file looks a lot like mine:

http://dropbox.github.io/dropbox-sdk-obj-c/api-docs/latest/index.html#download-style-request

 

[[[client.filesRoutes downloadUrl:@"/test/path/in/Dropbox/account" overwrite:YES destination:outputUrl]
    setResponseBlock:^(DBFILESFileMetadata *result, DBFILESDownloadError *routeError, DBRequestError *networkError,
                       NSURL *destination) {
      if (result) {
        NSLog(@"%@\n", result);
        NSData *data = [[NSFileManager defaultManager] contentsAtPath:[destination path]];
        NSString *dataStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
        NSLog(@"%@\n", dataStr);
      } else {
        NSLog(@"%@\n%@\n", routeError, networkError);
      }
    }] progress:^(int64_t bytesDownloaded, int64_t totalBytesDownloaded, int64_t totalBytesExpectedToDownload) {
  NSLog(@"%lld\n%lld\n%lld\n", bytesDownloaded, totalBytesDownloaded, totalBytesExpectedToDownload);
}];

 

Can you tell what I am doing wrong from what I've listed here?

 

Also, has the process for getting and saving OAuth2Tokens from OAuth1Tokens changed?  That function you gave me, "

getAndSaveOAuth2TokensFromRetrievedOAuth1Tokens" has some errors, and in the documentation it looks like there is a whole new way of doing this: https://github.com/dropbox/dropbox-sdk-obj-c#migrating-oauth-tokens-from-earlier-sdks

 

 

Man this is kind of overwhelming, did I just pick the absolute wrong time to upgrade Dropbox back in January, like a week before you guys decided to change everything in the SDK?

 

 

Thanks

Bob

 

 

 

Re: DropboxClientsManager authorizeFromController not doing anything

Greg-DB
Dropboxer

Yes, unfortunately we had to drop support for iOS 8. (This is because we are moving to Safari View Controller, in order to better support the Google Sign In flow, which no longer allows web views: https://developers.googleblog.com/2016/08/modernizing-oauth-interactions-in-native-apps.html , among other features.)

 

You can technically use an older version of the SDK, but it's not reccomended. (E.g., the Google Sign In flow will stop working in the web view, though you can make sure you set browserAuth:YES to support that.)

 

Anyway, apologies there were a lot of changes! You can find information in the release log. For example, "progress" changed to "setProgressBlock", and "response" changed to "setResponseBlock".

 

And yes, you can now use checkAndPerformV1TokenMigration, which we more recently built in to the SDK, using the same mechanisms we discussed earlier this year when working out getAndSaveOAuth2TokensFromRetrievedOAuth1Tokens with you.

Re: DropboxClientsManager authorizeFromController not doing anything

Bob S.15
Collaborator | Level 8

I think part of the problem is that the documentation has not kept up with the changes -- for example, the release notes state that the browserAuth argument was dropped from authorizeFromController, but the API reference still lists it.

 

And the example for how to download a file shows 'setResponseBlock', but it does NOT show 'setProgressBlock'.   It still says 'progress'.    

 

This is especially important since that demo describes how to call that whole class of functions and that's the only place I have found where it is demonstrated.  It's not even part of the function definitions themselves.  First of all there's no easy way to find the actual function definitions.  Like WHERE is the function definition for 'downloadURL'?  It is such an important function, yet searching for it from the main API page doesn't reveal it.   To find that function I have to look at my code, see that DBClientsManager has a member called authorizedClient, which is of type DBUserClient.  Click  that and then click on DBUserBaseClient when you don't see filesRoutes listed.  Only then can you find that filesRoutes is of type DBFILESUserAuthRoutes, click on it and finally find the function definition for downloadURL.  But even then, there is nothing on the documentation page for downloadURL which suggests that it must be called with extra arguments 'setResponseBlock' and 'setProgressBlock'!  How is someone supposed to know that?!   

 

Sorry for the rant -- but the API page could really use a search function, and those functions which require response and progress block arguments should say that.

 

Anyway, I got everything compiled in both of my apps and am back to square one.  I've got one app which works fine, and the other one just ignores the calls to authorize the user.  

 

 

 

 

 

 

 

 

 

 

Re: DropboxClientsManager authorizeFromController not doing anything

Greg-DB
Dropboxer

Thanks for pointing out the old examples! We'll get that fixed up in the documentation.

 

 

And thanks for the rest of the feedback on the documentation! It's much appreciated.

 

Anyway, regarding the issue of authorizeFromController not working, since it's working in your other app and the sample app, it seems like the issue must be specific to that one app. To make sure of that though, can you confirm if you tested the working apps on the same device as the not working app? Also, to eliminate other variables, do you have the same version of the SDK installed in both?

 

Finally, it would be helpful if we could reproduce the issue. Is the problematic app available in the US App Store for us to try?

Re: DropboxClientsManager authorizeFromController not doing anything

Bob S.15
Collaborator | Level 8

Yes, it must be something specific to this app.  This app is from 2008 and has some very old funky viewController stuff going on -- so I suspect it has something to do with that.  It may be due to recent iOS SDK changes rather than Dropbox SDK stuff.  But yeah I am testing on the same devices and simulators, same SDK version.

 

The app is in the store but it doesn't have the new Dropbox SDK stuff.  The one in the store is still using the old API v1.

 

Bob

 

Re: DropboxClientsManager authorizeFromController not doing anything

Greg-DB
Dropboxer
Thanks! If it is due to an unusual view controller setup it's unlikely we'll be able to help without seeing more code. Would you be able to share the relevant code, and send us a build we can try? You can write in privately here if you'd prefer:

https://www.dropbox.com/developers/contact

Re: DropboxClientsManager authorizeFromController not doing anything

Bob S.15
Collaborator | Level 8

Man, you do not want to see this code.  It is like a building that people have added multiple floors to, with extra sheds and carparks and a kitchen in back.  I would be ashamed to show it to anyone, and it is freaking huge too.  

 

The one thing that makes me think it doesn't have to do with viewControllers, however,  is that in the other app, the one that works, it doesn't open a viewController when I authorize.  It opens the Dropbox app.  So I assume this broken app would do the same thing.

Re: DropboxClientsManager authorizeFromController not doing anything

Bob S.15
Collaborator | Level 8

Greg how do I determine which version of the SDK I have?  I set my Cartfile to ~> 3.0.11, but I just noticed that in the shell when I run the update, it says Checking out dropbox-sdk-obj-c at "3.0.14".  I am compiling with a deployment target of 8.0 and not getting any errors -- does that mean it would just crash on an iOS 8 machine or just not connect?

Re: DropboxClientsManager authorizeFromController not doing anything

Greg-DB
Dropboxer

You don't have to share your code if you don't want to, but for what it's worth, we won't judge your code! 🙂

 

If the view controller setup seems unlikely to be the problem, perhaps it's something to do with the UIApplication? Is there anything unusual about your [UIApplication sharedApplication] in that app?

 

In any case, if it helps, the SDK is open source so you can see the definition for authorizeFromController here:

 

https://github.com/dropbox/dropbox-sdk-obj-c/blob/94f7b0cfe5f1bc489b382ed009f3e28c945bf7ec/Source/Ob...

 

But yes, with the broken app we would also expect the official Dropbox app to get launched if it's installed. It checks if the app is installed first using canOpenUrl via the passed along UIApplication, and then opens it using openUrl, if so. It's possible it's failing somewhere there, but I've always seen output when something goes wrong with that. 

 

Also, as another data point, have you tried it on multiple devices?

 

And you can programmatically check the SDK version using the kV2SDKVersion constant. Or, you can check the installed version manually in the Cartfile.resolved file. The "~>" Carthage operator is how you request a "compatible" version, so "~> 3.0.11" will give you "3.0.14", for example.

 

I'm not sure offhand what the expected failure mode is when attempting to use it on iOS 8, but I would expect it to crash, at least during the app authorization flow if not at launch.

Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
  • User avatar
    srinivas1995 Explorer | Level 3
  • User avatar
    Bob S.15 Collaborator | Level 8
What do Dropbox user levels mean?
Need more support?