cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How do I create a shared link with expiry date from API (Python SDK)?

How do I create a shared link with expiry date from API (Python SDK)?

Florian K.8
New member | Level 1
9 Replies 9

Greg-DB
Dropbox Staff

The Dropbox API doesn't currently offer a way to set a custom expiration on shared links, but I'll be sure to pass this along as a feature request.

Peter K.11
New member | Level 1

what about setting the password on shared links ? 

Greg-DB
Dropbox Staff

That's also not currently available, but I'll pass that along as a request as well.

Daniel B.70
New member | Level 1

Is there any expected/known timeline for this?

 

Thanks!

Greg-DB
Dropbox Staff

This is now possible using the /sharing/create_shared_link_with_settings endpoint on API v2:

https://www.dropbox.com/developers/documentation/http/documentation#sharing-create_shared_link_with_...

In the latest version of the Python SDK, that's the sharing_create_shared_link_with_settings method:

https://dropbox-sdk-python.readthedocs.org/en/master/moduledoc.html#dropbox.dropbox.Dropbox.sharing_...

Daniel B.70
New member | Level 1

Oh! great, I was looking at v1 docs. Thank you very much!

Russell A.1
New member | Level 1

sorry to revive this, but can someone show an example of how to pass settings here? Like:

 

dbx = dropbox.Dropbox("KEY")
dbx.users_get_current_account()
print dbx.sharing_create_shared_link_with_settings('link/to/share', ????)

I'm not sure how to pass the settings, like requested_visibility or link_password.

Greg-DB
Dropbox Staff

Sure, this creates 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)

print(shared_link_metadata)

<ACCESS_TOKEN> should be replaced with the access token.

The dropbox.sharing.SharedLinkSettings constructor also takes a link_password parameter.

Russell A.1
New member | Level 1

okay that's great.  thank you so much.  that really put that in perspective!

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Russell A.1 New member | Level 1
  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Daniel B.70 New member | Level 1
What do Dropbox user levels mean?