How can write curl command to upload file into dropbox with refresh code?

showkey

Upload file with access token in curl command:

access_token="xxxxxxx"
remote_path="/dir_dropbox/fname.txt"
local_path="/tmp/fname.txt"
curl -X POST https://content.dropboxapi.com/2/files/upload \
    --header "Authorization: Bearer $access_token" \
    --header "Dropbox-API-Arg: {\"path\": \"$remote_path\"}" \
    --header "Content-Type: application/octet-stream" \
    --data-binary @$local_path

Now i create a refresh code ,How can write curl command to upload file into dropbox with it?

refresh_token="xxxxxxx"
remote_path="/dir_dropbox/fname.txt"
local_path="/tmp/fname.txt"
curl -X POST https://content.dropboxapi.com/2/files/upload \
    --header "Authorization: Bearer $refresh_token" \
    --header "Dropbox-API-Arg: {\"path\": \"$remote_path\"}" \
    --header "Content-Type: application/octet-stream" \
    --data-binary @$local_path

It can't work!

Greg

Refresh tokens are not access tokens, and cannot be used like access tokens. That is, you can't use a refresh token as a Bearer token in the Authorization header.

Instead, you can use a refresh token to perform a different call first to retrieve a new access token. The call to use a refresh token to retrieve an access token would look like this: (taken from the documentation for the Dropbox /oauth2/token endpoint)

curl https://api.dropbox.com/oauth2/token \
    -d grant_type=refresh_token \
    -d refresh_token=<REFRESH_TOKEN> \
    -u <APP_KEY>:<APP_SECRET>

Once you get the access token from the response to that call, you can then proceed to use it to call the API, e.g., /2/files/upload, normally.

You can find more information in the following resources:

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to write output of looped curl command to file

How to write a Dropbox Curl request in PHP Curl?

Upload zip file via Dropbox Api and curl

Using CURL to upload to Dropbox and overwrite a file

cURL command to upload file does not upload file

How to upload file to Dropbox with axios

How can I upload a file on dropbox without using a dropbox SDK in Java?

How can I transform this curl command into php curl code?

How can I upload a file using `curl` instead of the form?

How can I write the javascript equivalent for cURL code?

Equivalent to curl command in axios (nodejs) for file upload?

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

Upload a file into dropbox folder

Dropbox api upload file

how can i refresh the php file using javascript code?

How can i upload file by command line via sftp?

Can't upload file to a server using curl

Can't upload file via curl

How can I write this code better? Is it correct to use the switch command in this?

curl write http code to stderr or to file

How can I write Windows batch file command with loop and % operator?

How can I write to the second line of a file from the command line?

How to write the curl command to imitate get method?

How Can I use Dropbox Refresh Tokens in Google Apps Script to transfer Drive Files to Dropbox?

How are file upload forms are designed in WebServer and How Curl can use them to POST files?

How to upload file into target directory with curl?

How to use cURL in Windows to upload a file to Alfresco?

how to upload file using curl with php

How to use cURL to upload a file as a GET request

TOP Ranking

HotTag

Archive