Forum Discussion

rf27's avatar
rf27
New member | Level 2
9 years ago

Generate links and passwords with Python

Hi,

 

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.

 

Thanks

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    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:

     

    import datetime

    import dropbox

    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)

    print(shared_link_metadata)

    `<ACCESS_TOKEN>` should be replaced with the access token.

     

     In your case, you'd want to use RequestedVisibility.password instead of team_only.

    • dbower's avatar
      dbower
      New member | Level 2

      Most of the links in the above message no longer work.  Is it possible to re-link the references, or delete the message?

      • Greg-DB's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff

        dbower Thanks for letting me know! I've updated my post to fix those issues.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,947 PostsLatest Activity: 53 minutes ago
351 Following

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 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!