cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more 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: 

sharing_get_file_metadata access error

sharing_get_file_metadata access error

Cato2021
Explorer | Level 4

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 

4 Replies 4

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.

Cato2021
Explorer | 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.

Cato2021
Explorer | 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)


image.png

Greg-DB
Dropbox Staff

Yes, that would just show the shared link policy for that folder; the effective policy for any particular sharing/link for content on a team would take into account all of the relevant policies (e.g., for the specific folder as well as the team itself).

 

To check for existing shared links for any specific file or folder, you would use sharing_list_shared_links. To see which accounts, if any, a file is specifically shared with, you would use sharing_list_file_members/sharing_list_file_members_continue/sharing_list_file_members_batch.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Cato2021 Explorer | Level 4
What do Dropbox user levels mean?