cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Retrieve Shared URL with JavaScript SDK without Authentication

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
Highlighted

Re: Retrieve Shared URL with JavaScript SDK without Authentication

Dropboxer
Dropboxer
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.
Highlighted

Re: Retrieve Shared URL with JavaScript SDK without Authentication

Helpful | Level 6

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)

Highlighted

Re: Retrieve Shared URL with JavaScript SDK without Authentication

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.

Highlighted

Re: Retrieve Shared URL with JavaScript SDK without Authentication

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?

Highlighted

Re: Retrieve Shared URL with JavaScript SDK without Authentication

Dropboxer
Dropboxer

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

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?