Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
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;
}
}
When setting options like this, you should use the provided instance, like this:
var visibility = RequestedVisibility.Public.Instance;
Also, I see you're checking the "RequestedVisibility" in the result, but you probably want to actually check "ResolvedVisibility", since that's what tells you what the final state actually is (e.g., once team policies were taken into account as well).
When setting options like this, you should use the provided instance, like this:
var visibility = RequestedVisibility.Public.Instance;
Also, I see you're checking the "RequestedVisibility" in the result, but you probably want to actually check "ResolvedVisibility", since that's what tells you what the final state actually is (e.g., once team policies were taken into account as well).
Awesome, that just worked. I'm a little uncomfortable dealing with static initializers instead of constructors, but our team will refactor as necessary.
Hi there!
If you need more help you can view your support options (expected response time for a 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!