Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
Hi all,
is there a way to set the expiration duration for a Temporary Link in the API? The generated one expires within 4 hours by default. I’m thinking of setting it to 24 hours or so. I’ve seen that it’s possible with the sharing_create_shared_link_with_settings, but that’s not the kind of link I need/want to use, and also I want to avoid using a UI (or the web link from above).
Thanks for the reply and for forwarding it as a feature request. I can imagine that others can benefit from it as well 🙂
mark2mark,
Greg already linked to the docs on this, but just to be clear...you don't have to use the UI for sharing_create_shared_link_with_settings type of links. If you get a shared link with that API and then replace "?dl=0" with "?raw=1" that links will function almost identically to the 4-hour temporary links. That'll probably work for you? The one caveat is that to access the full file data you'll have to follow a redirect or two first.
(something I've noticed is that Dropbox never serves the bytes of files directly from the www.dropbox.com. A file's bytes always come from different domain/subdomains)
(also it's pretty ugly that every shared link you get this way has "?dl=0" on it. It seems like it's just telling the server that dl (download) equals 0 (false) which is also the default. If you remove "?dl=0" the links still work fine but now you helpfully have the file/folder name at the end of the URL instead of that query args which is gobbleygook to the majority of people)
Thanks for the replies!
I am a bit confused by the documentation and my result.
import sys, json, datetime nowPlusAddedHours = datetime.datetime.now() + datetime.timedelta(hours=24) nowPlusAddedHours = str(nowPlusAddedHours.isoformat()[:19] + "Z") if (3,0) <= sys.version_info < (4,0): import http.client as httplib elif (2,6) <= sys.version_info < (3,0): import httplib headers = { "Authorization": "Bearer %s" % access_token, "Content-Type": "application/json" } params = { "path": "/FOLDER/FILE.zip", "settings": {"requested_visibility":{".tag":"public"},"expires":nowPlusAddedHours} } c = httplib.HTTPSConnection("api.dropboxapi.com") c.request("POST", "/2/sharing/create_shared_link_with_settings", json.dumps(params), headers) r = c.getresponse() print r.read()
I know that my access token is valid, but i get an error:
{"error_summary": "settings_error/not_authorized/...", "error": {".tag": "settings_error", "settings_error": {".tag": "not_authorized"}}}
@mark2mark Are you using a free account? Note that only paid accounts have access to the link expiration feature. You can find more information under the error documentation for the endpoint:
Hi @Greg-DB I did not see that. Thanks for pointing it out. I got a business account for my company related stuff, but I don’t want to rely on it. I guess I have to wait for the implementation of settings for the temporary link then. I’m aware of that it might not even happen.
Hi there!
If you need more help you can view your support options (expected response time for a 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!