Dropbox API Creating a shared link for a file with expiration and visibility settings using the Dropbox Python library


This uses the Dropbox Python SDK to create a shared link for a file and also supplies a requested visibility and expiration in the settings:

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)


<ACCESS_TOKEN> should be replaced with the access token.