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: 

Expiration settings of Temporary Link

Expiration settings of Temporary Link

mark2mark
Helpful | Level 7

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).

6 Replies 6

Greg-DB
Dropbox Staff
No, it's not possible to set arbitrary expirations on those temporary links, but I'll pass this along as a feature request.

Note that you can modify the shared links from sharing_create_shared_link_with_settings for different behaviors if that helps:

https://www.dropbox.com/help/desktop-web/force-download

mark2mark
Helpful | Level 7

Thanks for the reply and for forwarding it as a feature request. I can imagine that others can benefit from it as well 🙂

thelwang
Helpful | Level 7

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)

mark2mark
Helpful | Level 7

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"}}}

Greg-DB
Dropbox Staff

@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:

 

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

mark2mark
Helpful | Level 7

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.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    mark2mark Helpful | Level 7
  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    thelwang Helpful | Level 7
What do Dropbox user levels mean?