Hello everyone,
Seems that there's an issue in the SDK with modifying shared link settings. I am using Dropbox.Api Nuget V6.13.0. with an Admin-accessed internal app. I am able to set up passwords on client folders, but I am unable to remove passwords on those folders through the API. To expand, the SetLinkPassword() method successfully processes and changes the link status to password. However, the RemoveLinkPassword() method successfully process, but does not remove the password.
Here's the code in C#.
// This is the NUnit test. client.DropboxSharedURL is the URL to the client's folder, which they have View access to.
[Fact]
public async Task SetSamplePassword()
{
var clients = Clients.Read();
var client = clients[1000];
string password = "testpassword";
await Password.SetLinkPassword(client.DropboxSharedURL, password);
Assert.Equal(true, await Password.HasPassword(client.DropboxSharedURL));
await Password.RemoveLinkPassword(client.DropboxSharedURL);
Assert.Equal(false, await Password.HasPassword(client.DropboxSharedURL));
} //These are the two methods I am using to set/reset the Link password.
public static async Task SetLinkPassword(string url, string password)
{
var accesslevel = new RequestedLinkAccessLevel().AsViewer;
var audience = new LinkAudience().AsPassword;
var sharedlinksettings = new SharedLinkSettings(true, password, null, audience, accesslevel, null, true);
await user.Sharing.ModifySharedLinkSettingsAsync(url, sharedlinksettings, false);
}
public static async Task RemoveLinkPassword(string url)
{
var accesslevel = new RequestedLinkAccessLevel().AsViewer;
var audience = new LinkAudience().AsPublic;
var visibility = new RequestedVisibility().AsPublic;
var sharedlinksettings = new SharedLinkSettings(false, null, null, audience, accesslevel, visibility);
await user.Sharing.ModifySharedLinkSettingsAsync(url, sharedlinksettings, false);
}//This checks if a link has a password.
public static async Task<bool?> HasPassword(string url)
{
try
{
var metadata = await user.Sharing.GetSharedLinkMetadataAsync(url);
return metadata.LinkPermissions.RequestedVisibility.IsPassword;
}
catch
{
return null;
}
}