Forum Discussion

kir_ko's avatar
kir_ko
Helpful | Level 5
5 years ago

Shared link metadata object returns incorrect IsPassword in dropbox-sdk-dotnet

Got a file shared via view/edit link for anyone/team with password. In API explorer I call the 'get_shared_link_metadata' for the file and clearly see the raw response has all the properties correct including the 'link_permissions.require_password' one (true in my case). But retrieving the link metadata using dropbox-sdk-dotnet for the same file I face the fact that Sharing.FileLinkMetadata.LinkPermissions object returns false for any *password* property. I think that at least the LinkPermissions.EffectiveAudience.IsPassword property is supposed to be true. Also not really clear for me why the LinkPermissions.EffectiveAudience object doesn't contain the IsTeamAndPassword property while LinkPermissions.ResolvedVisibility does? Thanks!

8 Replies

Replies have been turned off for this discussion
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    5 years ago

    Could you share the relevant code you're using and output you're getting so we can look at what you're seeing specifically? Thanks in advance!

  • kir_ko's avatar
    kir_ko
    Helpful | Level 5
    5 years ago

    Thanks for the response! Sure, there it is step-by-step:

    1) The .paper file shared for team members with password required

    2) 

    namespace PatchTest
    {
        using Dropbox.Api;
        using Dropbox.Api.Common;
        using System;
    
        class Program
        {       
            static void Main(string[] args)
            {
                var link = @"https://www.dropbox.com/_cut_/public_paper_team_members_with_password_can_edit.paper?dl=0&rlkey=_cut_";           
                var namespaceId = "_cut_";
                var memberId = "_cut_";
                var accessToken = "_cut_";
                var config = new DropboxClientConfig("");
                var teamClient = new DropboxTeamClient(accessToken, config);
                var userClient = teamClient.AsMember(memberId).WithPathRoot(new PathRoot.NamespaceId(namespaceId));           
                var sharedLinkMetadata = userClient.Sharing.GetSharedLinkMetadataAsync(link).Result;          
    
                Console.ReadKey();
            }        
        }
    }

     3) And what we get as a result (IsTeam resolved properly while IsPassword is incorrect):

     

    The LinkPermissions.RequirePassword==true property you can see on the screenshot is an example that the proper value can be found. I added the property to Dropbox.Api.Sharing.LinkPermissions class and added another switch to the LinkPermissionsDecoder.SetField method:

    private class LinkPermissionsDecoder : enc.StructDecoder<LinkPermissions>
            {
                ...
    
                protected override void SetField(LinkPermissions value, string fieldName, enc.IJsonReader reader)
                {
                    switch (fieldName)
                    {
                        case "require_password":
                            value.RequirePassword = enc.BooleanDecoder.Instance.Decode(reader);
                            break;
                        case "can_revoke":
                            value.CanRevoke = enc.BooleanDecoder.Instance.Decode(reader);
                            break;
                        case "resolved_visibility":
    ...

     

    Thanks.

  • kylea's avatar
    kylea
    Icon for Dropbox Staff rankDropbox Staff
    5 years ago

    Just to confirm: 

    • The property is true when you executed the HTTPS call (in the Dropbox API explorer or other), but the property is returning false in the SDK?
    • Including the line to LinkPermissionsDecoder resolved? 
  • kir_ko's avatar
    kir_ko
    Helpful | Level 5
    5 years ago
    • The property is true when you executed the HTTPS call (in the Dropbox API explorer or other), but the property is returning false in the SDK? - Yes, Sir.
    • Including the line to LinkPermissionsDecoder resolved? - Sorry, the question is not clear for me. If you mean including the line to my local copy of dropbox-sdk-dotnet is a solution then the answer is no, forking each sdk release in local repo seems like a wrong idea -)
  • kylea's avatar
    kylea
    Icon for Dropbox Staff rankDropbox Staff
    5 years ago

    I'm not suggesting forking the SDK is a sustainable solution; I'm just confirming if the lines you added worked 😀. I'll be tracking it as a bug in the SDK.

  • kir_ko's avatar
    kir_ko
    Helpful | Level 5
    5 years ago

    Ah, OK, got it. So yep, those lines worked fine and returned 'true' I was searching for 😉

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

    kir_ko These properties, such as LinkPermissions.RequirePassword, should now be available in the SDK as of v6.10.2.

  • kir_ko's avatar
    kir_ko
    Helpful | Level 5
    5 years ago

    Greg-DB Thanks a lot! After July 19th I'll download the 6.10.2 version and update my methods accordingly. Will update the discussion when done.

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!