We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
biswas_nu
3 months agoNew member | Level 2
Listing team folders and content
I need a critical help with question below. i am developing a backup and restore solution which backups data from dropbox and store in s3 bucket. I am using typescript lambda to achieve the same
Now I have been so far successful listing the users in a dropbiox business account and listing their files and folders successfully
Some snippets of code related to it are
- List users: https://api.dropboxapi.com/2/team/members/list_v2
- Fetch team_member_id for these users
- Create dropbox client using
const dbx: any = new Dropbox({ accessToken: access_token, fetch: fetch, selectUser: team_member_id });
- Recursively call below to get all files and folders for that particular team member. Please note the access token is obtained using oauth flow using admin account
if (cursor === "") { result = await retry(() => dbx.filesListFolder({ path: "", recursive: true })); } else { result = await retry(() => dbx.filesListFolderContinue({ cursor })); }
Now I need to list all the team folders and its content too along with user specific content For it I tried
- Getting list of team folders using : const teamFolderUrl = 'https://api.dropboxapi.com/2/team/team_folder/list';
- Get the team_folder_id
- Create dropbox client using
const dbx: any = new Dropbox({ accessToken: access_token, fetch: fetch, });
- Recursively call below to get all files and folders for that particular team member. Please note the access token is obtained using oauth flow using admin account
if (cursor === "") { result = await retry(() => dbx.filesListFolder({ path: "/team_folder", recursive: true })); } else { result = await retry(() => dbx.filesListFolderContinue({ cursor })); }
but I am getting error
error: `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>.`
require your help in detailed understanding of the issue
- ЗдравкоLegendary | Level 20
biswas_nu wrote:...
require your help in detailed understanding of the issue
Hi biswas_nu,
Your issue is that tokens don't impersonate anybody personally when they authenticate a team. File access of any type require user/member to be acting though (the team on its own cannot be acting side)! That's why you need to add member information while working on team account files with team tokens as noted in the error message. One thing that is missing in the error message is that you can make team folder content list as admin too, not only as user having access to there (i.e. you may and have to use either selectAdmin or selectUser option).
Hope this helps.
- biswas_nuNew member | Level 2
This value comes however in case of user file
2024-09-13T12:33:46.823Z 7b23231c-d109-59e2-9a4e-7c42e2455f91 INFO Entry for normal file: {
'.tag': 'file',
name: 'IMG_2234.MOV',
path_lower: '/cloudportal_restore_05c52d00-701f-11ef-ae02-55ed4bd144bc/photos and videos/saaher iphone 5s/965yokdj/img_2234.mov',
path_display: '/CloudPortal_Restore_05c52d00-701f-11ef-ae02-55ed4bd144bc/Photos and Videos/Saaher iphone 5s/965YOKDJ/IMG_2234.MOV',
id: 'id:bIDhMLTvgPsAAAAAAAAVzw',
client_modified: '2024-09-11T09:23:21Z',
server_modified: '2024-09-11T09:23:22Z',
rev: '01621d48a95676d00000001314ef691',
size: 26728433,
is_downloadable: true,
content_hash: '77da2ab8c10808a72062a8cb809543f8372ba763519fdea0ff6d59b4c76eaa57'
}- ЗдравкоLegendary | Level 20
biswas_nu wrote:This value comes however in case of user file
...
Hm..🤔 To be honest, I'm not certain what exactly you mean here.
If you mean that when you get token for non-team account or token for a team member without team scopes it works, then of course would be strange to be otherwise. Such a token doesn't represent a team, but a person (either as an account owner or pointing precise team member - not the entire team). That's why in such a case you don't need to specify exact person explicitly - it's already specified on authentication and associated to the token.
If you mean something else, clarify what you mean exactly.
Hope this clarifies matter.
- Greg-DBDropbox Staff
[Cross-linking for reference: https://stackoverflow.com/questions/78980867/issue-listing-team-folders-with-dropbox-javascript-sdk ]
I see Здравко already helpfully offered some guidance here. The following resources may also serve as useful references:
- https://www.dropbox.com/developers/documentation/http/teams#teams-member-file-access
- https://dropbox.tech/developers/listing-team-contents
If you have any remaining questions, feel free to reply and clarify.
About Discuss Dropbox Developer & API
Make connections with other developers
795 PostsLatest Activity: 7 days agoIf you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!