Forum Discussion

Cato2021's avatar
Cato2021
Explorer | Level 4
4 years ago

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 

4 Replies

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    4 years ago

    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's avatar
    Cato2021
    Explorer | Level 4
    4 years ago

    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's avatar
    Cato2021
    Explorer | Level 4
    4 years ago

    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)


  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    4 years ago

    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.

About Dropbox API Support & Feedback

Node avatar for 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!