You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

Steve_Neo's avatar
Steve_Neo
Explorer | Level 3
5 years ago

Can I use business app to access personal dropbox?

We provider an integration to our customers to upload files created by system.   It works well for personal account. Basically, the process is the customer use Dropbox File Brower pick a folder, and our system saves that folder and upload files.  However, I found this doesn't work if my customer is using Business Dropbox Account.  It looks I have to create a new Business API App to handle this.

So my question is,  should I create 2 APP for same function?   I want to make this transparent for my customers, is this possible? 

I use Python API, and use these functions currently:

users_get_current_account()
files_upload()
files_get_metadata()
files_create_folder_v2()
  • Greg-DB's avatar
    Greg-DB
    5 years ago

    Yes, you can use an access token for a non-Business app to access Business accounts, including team folders.

    First, for reference, the "Unexpected select user header" error is expected if you attempt to set the "Dropbox-API-Select-User" header when using an access token for a non-Business app, as that functionality is only needed for Business apps. You can remove that code and just use an access token for a non-Business app.

    To access different parts of an account, you should use the "Dropbox-API-Path-Root" functionality as you've already begun to, as seen in your code. Note that you don't need to set this manually if you're using the Python SDK though. You can use the Dropbox.with_path_root method to set it instead.

    For information on how to list and access different parts of Dropbox accounts, please review the Namespace Guide.

  • Steve_Neo's avatar
    Steve_Neo
    Explorer | Level 3

    Don't get answer yet. I made some progress and make the Business Account working with these methods.  However, it seems not possible to "tranparent" to end-user. Because Biz and Personal app token cannot be mixed when the user is connecting by Oatuh2. 

    That means, when the user connects the Dropbox,  I need to give them 2 options to ask if they want to login personal or business account.  Is that right?  Any possibility to use one app token? 

    • Greg-DB's avatar
      Greg-DB
      Icon for Dropbox Staff rankDropbox Staff

      Can you elaborate on what you meant when you said "this doesn't work if my customer is using Business Dropbox Account"? 

      You should certainly be able to use the particular methods you listed with both Business or non-Business accounts. You don't need to register separate apps in that case. A single "Dropbox API" app can be used for those Dropbox API methods for any account type.

      (If you do need to support both Business and non-Business accounts, and also need to use both Dropbox API methods, such as for file operations, and Dropbox Business API methods, such as for team operations like listing team members, then you would need to register two separate apps.)

      • Steve_Neo's avatar
        Steve_Neo
        Explorer | Level 3

        My App only need to these 3 methods: get metadata,  create folder and upload file.  If my user try to get_metadata of a team folder, I got this error by non-Business access token:

        'Error in call to API function "files/get_metadata": Unexpected select user header. Your app does not have permission to use this feature'

        Here is my code (Python):

         

        dbx = Dropbox(access.access_token)
        dbx_user = dbx.users_get_current_account()
          
        team_member_id = dbx_user.team_member_id
        team_root = PathRoot.namespace_id(dbx_user.root_info.root_namespace_id)
        
        # set headers
        dbx = Dropbox(access.access_token, headers={"Dropbox-API-Select-User": team_member_id, 'Dropbox-API-Path-Root': stone_serializers.json_encode(PathRoot_validator, team_root)})
        
        # here throw that permission issue:
        dbx.files_get_metadata(folder_id)

         

         

        However, I use business token,  use similar code - replaceusers_get_current_account() by 

        dbx_team.team_token_get_authenticated_admin()

        Then my app can use files_get_metadata() without issues.