cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox 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: 

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

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

kir_ko
Helpful | Level 5

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 8

Greg-DB
Dropbox Staff

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
Helpful | Level 5

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

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

kir_ko_0-1623067325977.png

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):

kir_ko_1-1623068272111.png

 

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
Dropbox Staff

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
Helpful | Level 5
  • 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
Dropbox Staff

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
Helpful | Level 5

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

Greg-DB
Dropbox Staff

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

kir_ko
Helpful | Level 5

@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.

Need more support?