The Maestral class is the primary public API for interacting with Dropbox. You can create an instance with a specific config_name to manage multiple Dropbox accounts. To link an account, use get_auth_url() to obtain an authorization URL, then pass the resulting token to link(). Once linked, you can set up a local directory and start the sync process.
Note: Maestral currently only supports macOS and Linux.
from maestral.main import Maestral
# Create a new configuration named 'private'
m = Maestral(config_name='private')
# Get the URL to authorize access
url = m.get_auth_url()
print(f'Please go to {url} to retrieve a Dropbox authorization token.')
# Enter the token from the website
token = input('Enter auth token: ')
# Link the account
res = m.link(token)
if res == 0:
# Set up the local Dropbox folder and start syncing
m.create_dropbox_directory('~/Dropbox (Private)')
m.start_sync()