0

We have a bunch of mixed up authenticated accounts from the past few years in our database, where some were given "Full Access" early on and later it was changed to just using the "App Folder".

Is there any way of using the API to know if the access_token we have is within an App Folder, or to the whole account?

We basically want to switch all accounts to App Folders, but only want to alter those that need it. We'll have to move folders and also store a default path in the DB.

Having looked through the documentation I can't see anything that gives this info, any thoughts?

1

2 Answers 2

0

The Dropbox API is designed so that the permission level (e.g., app folder vs full Dropbox) is transparent to the app, so there isn't a good/official programmatic way to detect the permission for any given access token. We'll consider this a feature request though.

That said, some features of the API are only accessible to full Dropbox apps, so you could use those as a way to implicitly detect the permission. For example, the /2/sharing/list_folders endpoint is only usable by full Dropbox apps:

Apps must have full Dropbox access to use this endpoint.

That could potentially work for you, though it's still not a great solution, since in the case of an app folder app, you'll get a 400 error with a plain text body (and not a nice structured 409 error) so you can't reliably tell the difference between that and some other 400 error. To work around that you could match against the error message, but that could change of course:

Error in call to API function "sharing/list_folders": Your API app is an "App Folder" app. It is not allowed to access this API function.

3
  • Thanks @Greg (again!)
    – spirie
    Commented Oct 12, 2016 at 17:57
  • Because sharing/list_folders doesnt return any errors I was unable to distinguish the difference between Full Access/App Folder.As a future reference i did the following:
    – spirie
    Commented Oct 13, 2016 at 19:23
  • I'm not sure I follow. You should be able to use /2/sharing/list_folders for this per my answer. It will yield a 400 error for app folder apps, and 200 for full Dropbox. (I think you're looking at the route-specific 409 errors, which /2/sharing/list_folders indeed doesn't have.)
    – Greg
    Commented Oct 13, 2016 at 19:53
0

Thanks to @Greg for pointing me in the right direction.

Because /sharing/list_folders doesn't return any errors I was unable to distinguish the difference between Full Dropbox & App Folder access.

For future reference, to solve my query I did the following:

  • Sent an API request to /sharing/get_folder_metadata with a made up shared_folder_id
  • This will always return an error (unless you somehow managed to pick a shared_folder_id that exists!)
  • If the error contained a response (which will always be invalid_id) then the access_token has Full Dropbox access
  • If the error was empty, then the access_token has only App Folder access

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.