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: 

Re: Retrieve Shared URL with JavaScript SDK without Authentication

Retrieve Shared URL with JavaScript SDK without Authentication

AlanDT
Explorer | Level 3

Hi, I am attempting to use the JavaScript SDK to retrieve a publicly shared URL.  This method succeeds if I first authenticate the user.

dbx.sharingGetSharedLinkFile({'url': sharedUrl}).then(...);

I would like to allow users of my application who do not have a Dropbox account to be able to access files shared by another user who does have a Dropbox account.  I was hoping to use some form of "App Authentication" without specifying a user.  If I simply provide my client id (with or without secret), I get "The given OAuth 2 access token is malformed."

 

All examples I've found show how to use the HTTP SDK, but I would prefer to use the JavaScript SDK.   Is there a way to access a shared link through the JavaScript SDK without having to authenticate the user?

5 Replies 5

Greg-DB
Dropbox Staff
The sharingGetSharedLinkFile method in the API v2 JavaScript SDK, as well as the corresponding /2/sharing/get_shared_link_file endpoint itself, do not support app authentication, so you will need an access token to call them unfortunately.

I'll send this along as a feature request for app authentication support for this, but I can't promise if/when that would be implemented.

thelwang
Helpful | Level 7

What do you want to do with the file at Dropbox's shared links?  Since its just a public link, all you should really be able to get from the link is the file. (the path/permisions/etc of the file in the user's dropbox are not public)

 

To just read the file, take the URL and replace "?dl=0" with "?raw=1".  You can try "dl=1" too but I think "raw=1" works better.

 

It seems a little hacky but Dropbox documents it here so they must be committed to supporting it: https://www.dropbox.com/help/desktop-web/force-download

 

(if you're downloading a folder, not sure what Dropbox does, probably gives you a zip. Also, make sure your app can follow redirects since Dropbox will bounce you around before returning the actual file)

AlanDT
Explorer | Level 3

First of all, thank you for your quick response.  This is a side project and the time I get to spend working on it is limited.  So my replies will probably not be so quck!  🙂

 

Thank you for the specific idea regarding changing the URL.  I had seen other posts about HTTP downloads, but had not run across this particular parameter change.

 

I'm writing a mobile Cordova app for a non-profit client who wants to use Dropbox as a way of sharing information publicly with others.  Eventually, Dropbox would be just one of several ways to share the information, as I've made the backend datastore adaptable.  I've had success using the JS Dropbox API to log-in and create the datastore as a series of files storing JSON objects.  There is a base file (e.g. index file) in the app directory which points to subdirectories with individual files.  Since the information is intended to be consumed publicly (through the same app), I cannot assume every consumer of the information can login or create a Dropbox account just to access the information.

 

Also, since the application is initially planned to be used in a third-world country, I would like to limit the amount of data transfer just to what is necessary.  Thus, downloading an entire directory (even zipped) may not be ideal.

 

In conclusion, I can use HTTP downloads to access the information if necessary; but I would prefer to use the JS API if at all possible.

AlanDT
Explorer | Level 3

Greg, thank you for your quick response and for putting in the feature request to access publicly available data without authenticating.  Please see my other response below for a more detailed account of what I'm attempting to do.  Perhaps there is another way I have not considered?

Greg-DB
Dropbox Staff

@AlanDT Thanks for following up. For public data sharing like this, the modified shared link method that thelwang reccomended may be a good alternative. 

Need more support?