One month down in 2025: How are your resolutions coming along? Check out how to get back on track here.
Forum Discussion
Cato2021
3 years agoExplorer | Level 4
sharing_get_file_metadata access error
Hello,
I want to get the file sharing information (such as how is it shared, if by link or who can view the file etc.)
so I'm using sharing_get_file_metadata with the admin team member id and the file id, but I get an access error:
GetFileMetadataError('access_error', SharingFileAccessError('invalid_file', None)
Even though the file is valid with files_get_metadata api (and the same file id)
This is the code:
dbx_t_as_admin = dbx_t.as_admin(<team_member_admin>)
namespaces_list_obj = dbx_t.team_namespaces_list()
for namespace_meta in namespaces_list_obj.namespaces:
ns = namespace_meta.namespace_id
files_meta = dbx_t_as_admin.files_list_folder(include_has_explicit_shared_members=True, path='ns:' + ns, recursive=True)
for file_meta in files_meta.entries:
type_ = str(type(file_meta))
if type_ == "<class 'dropbox.files.FileMetadata'>":
share_file_info = dbx_t_as_admin.sharing_get_file_metadata(file=file_meta.id)
The files are shared in the dropbox account.
Relevant information on one file_meta for example:
file_meta:
has_explicit_shared_members=True
parent_shared_folder_id=None
sharing_info=None
So why am I getting this error, the file is there and shared.
Another question:
Should I use a different api to retrieve that information?
btw the member id is the same member that has the file, he is also happened to be the admin.
Thank you in advance!
Greg-DB
- Greg-DB
Dropbox Staff
That endpoint only supports the "Team Admin" mode for "Dropbox-API-Select-Admin", meaning it "can access content of team folders and team spaces but not the team members' home namespaces". So, to be able to call that for files not in team folders/spaces, you'd need to use as_user with the relevant team member ID instead.
By the way, you can check the type of an object directly, e.g., to see if an entry is a FileMetadata, using instanceof like this.
Also, be sure to implement the pagination methods where applicable, to make sure you get all results, such as team_namespaces_list_continue and files_list_folder_continue.
- Cato2021Explorer | Level 4
Thank you! You are right, using as_user() method solved it.
But with sharing_get_file_metadata api I'm getting the file's policy that could be set and not the current status.
For example, I get SharedLinkPolicy('anyone', None) even though the file isn't shared with anyone.
Is there a way\api that gives the current status on a file:
e.g. is the file shared internally (within the team) or externally
by link or by invitation.
is it protected with a password
Thank you in advance.
or not shared at all.- Cato2021Explorer | Level 4
BTW the sharing settings are off as shown in the picture, then why the policy is still:
AclUpdatePolicy('editors', None)
MemberPolicy('anyone', None)
resolvedMemberPolicy('team', None)
SharedLinkPolicy('anyone', None)
ViewerInfoPolicy('enabled', None)
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,941 PostsLatest Activity: 3 hours ago
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 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!