I am looking to generate shared links with individual passwords for a lot of folders in one directory in Dropbox. Could you please give me some starter code or point me to more information for doing this?
Basically I would like to be able to loop through all the folder in a directoy, generate a share link for each with a unique password (either generated by Dropbox or supplied using some sort of randomiser function), and then saving these to a CSV.
If you could point me in the right direction that would be great.
If you're using Python, we recommend using the official Dropbox Python SDK. In that, you can use the sharing_create_shared_link_with_settings method to create a shared link for any file or folder. Here's an example of using that method:
dbx = dropbox.Dropbox("<ACCESS_TOKEN>")
expires = datetime.datetime.now() + datetime.timedelta(days=30)
requested_visibility = dropbox.sharing.RequestedVisibility.team_only
desired_shared_link_settings = dropbox.sharing.SharedLinkSettings(requested_visibility=requested_visibility, expires=expires)
shared_link_metadata = dbx.sharing_create_shared_link_with_settings("/test.txt", settings=desired_shared_link_settings)
`<ACCESS_TOKEN>` should be replaced with the access token.
In your case, you'd want to use RequestedVisibility.password instead of team_only.
@ShawnLyu You can find more information about the SharedLinkSettingsError.not_authorized error in the documentation here:
In short, you'll get that if you try to use a setting that isn't available to the account for the access token you're using. Free accounts can't set link passwords or expirations, for example.
@ShawnLyu It's not possible to create more than one distinct shared link per single file or folder, but I'll pass this along as a feature request.
That being the case, you'd need to either use the same shared link for each client, or make a copy of the file or folder for each client (and make a shared link for each copy).
The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.Sound good? Let's get started.
For more info on available support options, see this article.
If you found the answer to your question, please 'like' the post to say thanks to the user!