DropBox API PUT example using Curl and Oauth 2 to upload a file to DropBox

I search everywhere and could not find a suitable example, and I do not understand it enough to be able to sort it through documents. Can anyone with more knowledge than show me how to form a CURL team for OAUTH 2? And do I only need the OAUTH 2 secret key? They show me the application key, the application secret, and oauth 2. I use this in a perl script, if that matters.

The closest code I found is the following:

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 this is OAUTH 2?

+6
source share
2 answers

If you have an access token (created using the application console):

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

For an account, you need an access token. (This is usually achieved by going through the OAuth stream, but you can also get it for your account by clicking the "Create" button on your Dropbox app page. See https://www.dropbox.com/developers/blog/94/generate -an-access-token-for-your-own-account .)

Once you have the access token, your curl command should work, although I prefer --header "Authorization:Bearer abc123xyz" put the access token in the request parameter. Also, release Content-Type: multipart/mixed , as that is not what you are sending.

I would also recommend "auto" instead of "dropbox" because it always does the right thing regardless of the type of application.

+9
source

Source: https://habr.com/ru/post/980794/


All Articles