javascriptangulardropboxdropbox-apidropbox-sdk-js

Upload file to personal Dropbox from public website without exposing private key


I receive images for processing on my site and wanna omit uploading to local server and further adding to Dropbox folder from it by implementing direct upload to Dropbox from web browser.

Dropbox API is pretty simple, but has one problem - I need to expose API key to end user, and that key allows to download all pics from my account. Then if I use Dropbox API - one user can download images uploaded by others, and it's not acceptable scenario.

Is there any way to bypass limitation with exposing full access API key to website end users?


Solution

  • Unfortunately, no, in order to upload directly to Dropbox via the Dropbox API, the client needs the access token. Further, the Dropbox API doesn't offer an upload-only permission.

    Fundamentally, clients can't keep secrets, so any access token that exists client-side (in this case, in the browser) can be extracted and abused.


    Edit: The Dropbox API now offers some new pieces of functionality that may be useful here:

    A) The Dropbox API now offers "scopes", which you can use to configure an app or access token to only a limited set of functionality, such as the ability to write but not read files.

    You can find more information about the release in our blog post here:

    https://dropbox.tech/developers/now-available--scoped-apps-and-enhanced-permissions

    B) The Dropbox API now offers the /2/files/get_temporary_upload_link endpoint, which can be used to get a URL that a client can POST to in order to upload to a Dropbox account without an access token:

    https://www.dropbox.com/developers/documentation/http/documentation#files-get_temporary_upload_link