Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
biswas_nu
2 years 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
10 Replies
- Здравко2 years agoLegendary | 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_nu2 years agoNew 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'
} - Здравко2 years agoLegendary | 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-DB2 years ago
Dropbox Community Moderator
[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.
- biswas_nu2 years agoNew member | Level 2
Hello Legendary
Let me explain the problem in detail
- biswas_nu2 years agoNew member | Level 2
When using selectAdmin : <team_member_id of admin> and calling listfolder and listfoldercontinoue with the folder id, I am able to see all the files in team folder but not their path
- biswas_nu2 years agoNew member | Level 2
When using selectAdmin : <team_member_id of admin> and calling listfolder and listfoldercontinoue with the folder id, I am able to see all the files in team folder but not their path
the data does not contain the filePath for the team files - Здравко2 years agoLegendary | Level 20
biswas_nu, Can you take a look on your result posted above? You may see there files "path_lower" and "path_display". Do they absent in some of your list results? 🧐 That's the paths of all entries - files and folder in the list results.
Something that may confuse you is that such paths are rooted to the selected namespace (in your case - member home folders or shared team folders). Leading folder names are missing and if you don't know where you can find them - in your list results for such folders you made at the beginning (where your team_folder_id comes from).
Some other confusion may be incorrect paths symbols case - even in display paths. Only last entry in such a path is guaranteed correct. All preceding, if any, may be messed - messed path symbols case!
If something else confuse you, again, be more concrete.
- biswas_nu2 years agoNew member | Level 2
Hello Здравко
They are missing in case of team folder files when access them using selectAdmin: <team member id> - Здравко2 years agoLegendary | Level 20
Do you list inactive team folders by any chance? 🙂 They are not mounted! Paths appear to mounted folders only - all team folders or others.
About Discuss Dropbox Developer & API
Make connections with other developers
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If 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, Facebook or Instagram.
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!