Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 933
CRAIG Avatar asked Jan 10 '15 05:01

CRAIG


People also ask

How do I upload a file using curl?

How to send a file using Curl? To upload a file, use the -d command-line option and begin data with the @ symbol. If you start the data with @, the rest should be the file's name from which Curl will read the data and send it to the server. Curl will use the file extension to send the correct MIME data type.

How do I use Dropbox API?

Register a Dropbox API app To use the Dropbox API, you'll need to register a new app in the App Console. Select Dropbox API app and choose your app's permission. You'll need to use the app key created with this app to access API v2.

How do I get my Dropbox auth token?

If you'd like to quickly test out the Dropbox APIs using your own Dropbox account before implementing OAuth, you can generate an access token from your newly created app in My apps by pressing the button that says "Generate" in the OAuth 2 section of your app settings page.


1 Answers

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>
like image 139
Hans Z. Avatar answered Oct 02 '22 17:10

Hans Z.