Cut the Clutter: Test Ignore Files Feature - sign up to become a beta tester here.
Forum Discussion
sprocketq
6 years agoExplorer | Level 3
Script (BAT or ps1) to download file from link that is password protected
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
- Greg-DB6 years ago
Dropbox Community Moderator
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.
- sprocketq6 years agoExplorer | 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-DB6 years ago
Dropbox Community Moderator
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.
- sprocketq6 years agoExplorer | 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-DB6 years ago
Dropbox Community Moderator
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.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,039 PostsLatest Activity: 2 days ago
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!