cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Script (BAT or ps1) to download file from link that is password protected

Script (BAT or ps1) to download file from link that is password protected

sprocketq
Explorer | Level 3

I have been searching for a way to create a bat script(prefered) or powershell script to download files from dropbox via link that are password protected. 

 

I have searched and found the curl might be able to do it, but all of the examples I have found do not work. 

Examples of what I have found:
https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_shared_link_file

curl -X POST https://content.dropboxapi.com/2/sharing/get_shared_link_file \
    --header "Authorization: Bearer " \
    --header "Dropbox-API-Arg: {\"url\": \"https://www.dropbox.com/s/2sn712vy1ovegw8/Prime_Numbers.txt?dl=0\",\"path\": \"/Prime_Numbers.txt\"}"


https://stackoverflow.com/questions/48895701/wget-to-access-password-protected-dropbox-link

 

curl -vX POST https://content.dropboxapi.com/2/sharing/get_shared_link_file \
    --header "Authorization: Bearer <ACCESS_TOKEN>" \
    --header "Dropbox-API-Arg: {\"url\": \"<SHARED_LINK>\",\"link_password\":\"<SHARED_LINK_PASSWORD>\"}" 

One of the errors I"m getting:

Error in call to API function "sharing/get_shared_link_file": Must provide HTTP header "Authorization" or URL parameter "authorization".* Connection #0 to host content.dropboxapi.com left intact
* Rebuilt URL to: \/
* Could not resolve host: \
* Closing connection 1
curl: (6) Could not resolve host: \
'--header' is not recognized as an internal or external command,
operable program or batch file.
'--header' is not recognized as an internal or external command,
operable program or batch file.

Any help would be greatly appreated. 

5 Replies 5

Greg-DB
Dropbox Staff

The /2/sharing/get_shared_link_file endpoint is the right way to download a file from a shared link using the Dropbox API, and the code samples looks correct in general. 

 

Based on the output you shared, it looks like the issue is with the formatting/escaping of the characters in the sample for the environment you're using. Specifically, it looks like those line continuations (using / ) are breaking, causing your client to send an incorrect request. 

 

You'll need to reformat the command to be formatted correctly for your environment. I recommend taking out the line continuations to start with, for the sake of simplicity. You may also need to check how you should escape the quote characters in your environment.

sprocketq
Explorer | Level 3

I've been doing more testing and research, do I have to generate a token to make this work? Is there a way to do this without creating an app token? 

Greg-DB
Dropbox Staff

The /2/sharing/get_shared_link_file endpoint does currently only support "user authentication" so it does require an access token. I'll pass this along as a feature request for a way to call this without an access token, but I can't promise if or when that might be implemented. 

sprocketq
Explorer | Level 3

Thanks @Greg-DB  

 

My goal is I am trying to create a script that my team can use to download files to client's machines on an as-needed use. I would like to password protect the files being downloaded and build that out into the script as an input. I'm trying to limit it to only nativiely built in options built into the Windows platform. 

 

Are there any other avenues I should look at, that I'm not thinking of? 

 

Greg-DB
Dropbox Staff

Dropbox does offer another way for programmatically downloading files from shared links, as documented here, but that doesn't offer an option for specifying a password. So, if you need to password-protect the link, that won't work. Dropbox doesn't offer anything like this beyond these two methods though.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    sprocketq Explorer | Level 3
What do Dropbox user levels mean?