cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Whether you are transferring a single drive, a team or an entire organization, Movebot's cloud migration tool has been built to make your Dropbox migration simple - learn 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: 

API V2 Access team folders of bussines plan with Folder/Files operations

API V2 Access team folders of bussines plan with Folder/Files operations

OLR_A
New member | Level 2

 i want to acces team folders using application user api for list,create folders, upload and download,etc.. and i'm going crazy.

In API Explorer  with function "list_folder",  only can acces user home folder, y try put in path the id of shared id,or namespace ns; does not work either,

The only way can view team folder stuff is put the shared link root, but the result of folders not contains the field path o lower_path ,that needs to files/folder operations like create folders/download/upload files etc..

 

Also try create folders / upload whith namespace ns: and return no write acces,the team folders have editor permissions.

 

I can't see any function to upload or create folders into shared folders.

 

I see this folders are mounted and can't unmounted it , theoricaly they would have to appear like shared folders when are mounted  when use function "list_folder"

 

can help me?

thnks

 

1 Accepted Solution

Accepted Solutions

Re: API V2 Access team folders of bussines plan with Folder/Files operations

Greg-DB
Dropboxer

It sounds like you're using a Business team with the new team space and member folders configuration that some teams have access to.

 

That being the case, you'll need to specify the team folder specifically when making API calls to access its contents, for example, by supplying the 'Dropbox-API-Path-Root' header. You can find more information on that here:

 

https://www.dropbox.com/developers/reference/namespace-guide

 

The Dropbox API Explorer is built for the older configuration, but we're working on updating the API and SDK support and documentation to support the new one. That's not quite ready yet though, so unfortunately there isn't a good way to use the API Explorer for this right now, but you can run it outside the of Explorer. Apologies for the inconvenience!

View solution in original post

10 Replies 10

Re: API V2 Access team folders of bussines plan with Folder/Files operations

Greg-DB
Dropboxer

It sounds like you're using a Business team with the new team space and member folders configuration that some teams have access to.

 

That being the case, you'll need to specify the team folder specifically when making API calls to access its contents, for example, by supplying the 'Dropbox-API-Path-Root' header. You can find more information on that here:

 

https://www.dropbox.com/developers/reference/namespace-guide

 

The Dropbox API Explorer is built for the older configuration, but we're working on updating the API and SDK support and documentation to support the new one. That's not quite ready yet though, so unfortunately there isn't a good way to use the API Explorer for this right now, but you can run it outside the of Explorer. Apologies for the inconvenience!

Re: API V2 Access team folders of bussines plan with Folder/Files operations

tianhong
New member | Level 2

HI Greg,

I have the same problem of accessing team shared folder. 

I tried to follow the namespace guide. I am using python. First get namespace ids:

"root_namespace_id": "4345996448",
"home_namespace_id": "4770419568",

Then create dbx object with a header:

header = {'Dropbox-API-Path-Root': {".tag": "namespace_id", "namespace_id": "4345996448"}}
dbx = dropbox.Dropbox(TOKEN, header)

But when do a 

dbx.files_list_folder('')

still showing my user's home dir, not team shared one. If I add 'ns:4345996448' to PATH, it would fail.

 

Can you help me with it? Thanks.

Re: API V2 Access team folders of bussines plan with Folder/Files operations

Greg-DB
Dropboxer

@tianhong To set the 'Dropbox-API-Path-Root' header, you should instead use the provided 'Dropbox.with_path_root' method, like this:

dbx = dropbox.Dropbox(TOKEN).with_path_root(dropbox.common.PathRoot.namespace_id("1990815600"))
dbx.files_list_folder('')

Re: API V2 Access team folders of bussines plan with Folder/Files operations

tianhong
New member | Level 2

Thanks Greg! It works. 

I am just wondering how to search these kinds of information in the documentation. I tried but failed. I don't think asking questions here is an efficient way, although your help is great.

Re: API V2 Access team folders of bussines plan with Folder/Files operations

Greg-DB
Dropboxer

@tianhong Thanks for the feedback! The documentation for the Python SDK is linked from the SDK's readme, and all of the options for the `Dropbox` class can be found on this `Dropbox` documentation page in particular. I certainly understand how that may not be very discoverable though, so we'll think about ways to make that better.

Re: API V2 Access team folders of bussines plan with Folder/Files operations

tomkr
New member | Level 2

Hi Greg, when I use this with the shared folders namespace ID :

 

dbx = dropbox.Dropbox(token).with_path_root(dropbox.common.PathRoot.namespace_id("6951349920"))
dbx.files_list_folder('')

I get the following error:

BadInputError('1cac57bc6ffa43f2ab66041af9f4dec7', 'Error in call to API function "files/list_folder": This API function operates on a single Dropbox account, but the OAuth 2 access token you provided is for an entire Dropbox Business team.  Since your API app key has team member file access permissions, you can operate on a team member\'s Dropbox by providing the "Dropbox-API-Select-User" HTTP header or "select_user" URL parameter to specify the exact user <https://www.dropbox.com/developers/documentation/http/teams>.')

I do not see in the documentation how to set the "select_user" or "Dropbox-API-Select-User" parameters in the python API.

 

When getting the member ID, would you use something like:


```

dbx = dropbox.DropboxTeam(token)
members = dbx.team_members_list()
member_id = members.members[0].profile.team_member_id

```

?

Re: API V2 Access team folders of bussines plan with Folder/Files operations

tomkr
New member | Level 2

As a quick update, when I set the header with: 

 

dbx_team = dropbox.DropboxTeam(token)
members = dbx_team.team_members_list()
member_id = members.members[0].profile.team_member_id

header = {"Dropbox-API-Select-User": member_id}

dbx = dropbox.Dropbox(token, header).with_path_root(dropbox.common.PathRoot.namespace_id("8378003952"))

 

I get the same error.

Re: API V2 Access team folders of bussines plan with Folder/Files operations

Greg-DB
Dropboxer

@tomkr This error message you're getting is referring to specifying what account on the Business team to operate on behalf of. For reference, when using any "team scopes", the resulting access token is connected to an entire Dropbox Business team, not an individual account. So, when using a team-scoped access token to access user-specific endpoints, such as files_list_folder, you will need to specify which member of the team you want to operate on behalf of. 

To do this, you'd need to specify the 'Dropbox-API-Select-User' header. The value should be the 'team_member_id' for whichever member you wish to act on behalf of, such as returned by team_members_list/team_members_list_continue, or team_members_get_info, etc. In the Python SDK, you can set the header using DropboxTeam.as_user.

Alternatively, if you just want to connect to a particular account, you can disable any team scopes and get a new access token without them. The access token without the team scopes will be specific to the particular account (Business or not) and so will not require the additional header. You can find more information on scopes in the OAuth Guide. If you don't need to call any team endpoints (e.g., if you just need to call file endpoints, such as files_list_folder), I recommend this solution instead for simplicity and security.

Re: API V2 Access team folders of bussines plan with Folder/Files operations

steve_r
New member | Level 2

Are there constants for the root_namespace_id and home_namespace_id? Seems unnecessary to have to call the 

api to retrieve the namespace IDs. Can you use a constant for the these IDs given the current user? For example:
dbx = dropbox.Dropbox(TOKEN).with_path_root(dropbox.common.PathRoot.namespace_id(".root"))
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
  • User avatar
    steve_r New member | Level 2
  • User avatar
    tomkr New member | Level 2
What do Dropbox user levels mean?
Need more support?