Example of DropBox API PUT using Curl and Oauth 2 to Upload a file to DropBox

CRAIG picture CRAIG · Jan 10, 2015 · Viewed 9.3k times · Source

I am searching everywhere and haven't been able to locate a suitable example and am not well versed enough to be able to sort it out via the docs. Could someone with more knowledge than I show me how to form the CURL command for OAUTH 2? And is it that I only need the OAUTH 2 secret key? I am being shown an App key, app secret and oauth 2. I am using this in a perl script if it matters.

The closest code I have found is this:

 curl --request PUT --header "Content-Length: `ls -la jonathan.txt | awk '{ print $5}'`" --header         
 "Content-Type: multipart/mixed" --data-binary "@jonathan.txt" "https://api-    
 content.dropbox.com/1/files_put/dropbox/jonathan.txt?access_token=ABCDEF"

But I don't think that is OAUTH 2?

Answer

Hans Z. picture Hans Z. · Jan 10, 2015

If you have an access token (created via the app console):

curl -H "Authorization: Bearer <your token>" https://api-content.dropbox.com/1/files_put/auto/ -T <your file path>