Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
JuliaNowicka
4 years agoExplorer | Level 4
Check if user has access to any shared folders
Hi, I'm trying to check if a user has access to any folders. My code at the moment is printing 'User has at least one shared folder' for everyone, but I'm not sure if that's correct. Could someone po...
- 4 years ago
[Cross-linking for reference: https://stackoverflow.com/questions/73558139/check-if-a-user-has-access-to-any-shared-folders-in-dropbox ]
Yes, for the Python SDK, using the sharing_list_folders/sharing_list_folders_continue methods is the right way to list the shared folders that a user account has access to. The Dropbox API doesn't offer a call just for returning a boolean indicating whether or not an account has any shared folders, so listing and counting them would be the right solution.
Note however that the sharing_list_folders method returns a ListFoldersResult, which is not itself the list of shared folders for that result page. That would be in ListFoldersResult.entries. So, you would instead need to do something like `if len(shared_folders.entries) == 0:` instead.
Also while the `limit` parameter sets a maximum page size, it doesn't technically guarantee a minimum page size, so to be safe it would be best to implement the pagination as documented and check the whole list, like this:
shared_folders = [] shared_folders_res = dbx.sharing_list_folders() shared_folders += shared_folders_res.entries while shared_folders_res.cursor: shared_folders_res = dbx.sharing_list_folders_continue(cursor=shared_folders_res.cursor) shared_folders += shared_folders_res.entries if len(shared_folders) == 0: print('User has no shared folders') else: print('User has at least one shared folder')
Greg-DB
Dropbox Community Moderator
4 years agoYes, team folders are considered a type of shared folder, so just building on the previous sample, you can do something like this:
team_folder_count = len([shared_folder for shared_folder in shared_folders if shared_folder.is_team_folder])
if team_folder_count == 0:
print('User has no team folders')
else:
print('User has at least one team folder')
print('User has %s team folder(s)' % team_folder_count)
Note though that this will only catch "team folders", not "team spaces". Any Dropbox Business team may be using one of those two different configurations. Check out the Team Files Guide for information on that.
JuliaNowicka
4 years agoExplorer | Level 4
Thank you Greg, I will try that.
About Dropbox API Support & Feedback
Find help with the Dropbox API from 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!