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: 

Re: Can I use business app to access personal dropbox?

Can I use business app to access personal dropbox?

Steve_Neo
Explorer | Level 3
Go to solution

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()
1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

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.

View solution in original post

6 Replies 6

Steve_Neo
Explorer | Level 3
Go to solution

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
Dropbox Staff
Go to solution

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
Explorer | Level 3
Go to solution

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. 

Steve_Neo
Explorer | Level 3
Go to solution

So my question could be, can I use non-Business app token to upload file to team folder?

Greg-DB
Dropbox Staff
Go to solution

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.

steveneo
Explorer | Level 3
Go to solution

Yes, it works now.  I think the major issue is I set the wrong permission on non-Business app. It should be "fullaccess".   

The reason I didn't use Dropbox.with_path_root method.  It is because it reset other HTTP headers, because I thought I should use both Dropbox-API-Select-User and root_path.   Anyway, this is not important now.  Thanks!

Need more support?