Forum Discussion

GustavBrock's avatar
GustavBrock
New member | Level 1
7 days ago
Solved

Owner account of shared folder

Using C# and the Dropbox API and having attached shared folders from another Dropbox accounts, how do I retrieve the Dropbox account ids that own these shared folders?

Both my account and the owners of the shared folders use Dropbox Basic, thus no teams.

I need this account id to identify the folder holding the files reported to my webhook.

  • Hi GustavBrock,

    Sending a request to /sharing/list_folder_members endpoint will return the members of a shared folder.

    For member groups, there will be a property "group_id" per member group. For individual members, there will be an "account_id" property per member.

  • DB-Des's avatar
    DB-Des
    Icon for Dropbox Engineer rankDropbox Engineer

    Hi GustavBrock,

    Sending a request to /sharing/list_folder_members endpoint will return the members of a shared folder.

    For member groups, there will be a property "group_id" per member group. For individual members, there will be an "account_id" property per member.

    • GustavBrock's avatar
      GustavBrock
      New member | Level 1

      Thanks!

      I have the Dropbox.Api package installed to serve other tasks. Could this be used to retrieve the account_id? I can retrieve the folder metadata but this seems not to include the account_id.

      • DB-Des's avatar
        DB-Des
        Icon for Dropbox Engineer rankDropbox Engineer

        Hi GustavBrock,

        In order to further assist, could you provide the following?

        • the name and version number of the platform and SDK/library you are using, if any
        • the steps to reproduce the issue, including relevant code snippet(s), but don't include any access or refresh token(s)
        • the full text of any error or unexpected output 
  • GustavBrock's avatar
    GustavBrock
    New member | Level 1

    It is 7.0.0

    I got it working. The https call responded with a missing scope error, because I hadn't set permission for sharing_read. That I did and reauthorized, and now also the Dropbox.Api code runs:

    internal async Task ListFiles(DropboxClient dbx)
    {
        List<Metadata> allFolders = new List<Metadata>();
    
        // <snip> .. fill allFolders
    
        foreach (var item in allFolders)
        {
            if (item.IsFolder)
            {
                Console.WriteLine($"{item.AsFolder.Id} - {item.Name}");
    
                string sharedFolderId = item.AsFolder.SharingInfo.SharedFolderId;
                var folderMembers = await dbx.Sharing.ListFolderMembersAsync(sharedFolderId);
                var owner = folderMembers.Users.Where(user => user.AccessType.IsOwner).FirstOrDefault();
                if (owner != null)
                {
                    Console.WriteLine($"Owner Account ID: {owner.User.AccountId}");
                }
                else
                {
                    Console.WriteLine("Owner not found.");
                }
            }
        }
    }

    Thank you. Have a nice weekend!

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,951 PostsLatest Activity: 16 minutes ago
352 Following

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!