17

How to use wget to download files from Onedrive? (and batch files and entire folders, if possible)

  • 1
    Please take a look at superuser.com/questions/833199/… "In Office 365 how do I get a direct download link for an Excel document stored in One Drive for Business?" to see if that answers your question. – steve Aug 17 '15 at 16:08
  • But is necessary subscripted account in Office365. – João José Aug 17 '15 at 16:48
  • Use the OneDrive client that someone has kindly written for Linux ? github.com/xybu/onedrive-d-old – steve Aug 17 '15 at 16:53
  • Try to download the file to your browser, while the download is running, right click and 'copy download link'. If you are lucky you can wget that link. – Baazigar Aug 17 '15 at 18:33
  • I try Onedrive-d, but couldn't do 'get' work. Really by copying link to file and put in 'wget', it works, thank you. – João José Aug 17 '15 at 20:12
12

There is one way that works for me (based on this tutorial: https://www.marstranslation.com/blog/how-to-make-direct-link-of-onedrive-files)

  1. Right-click on the file you are interested in download (from web interface), and choose Embed.

  2. Press "Generate HTML code to embed this file".

  3. Copy the part contained in the "" of src is your link. This will look like .

  4. Replace embed with download. This will look like https://onedrive.live.com/download?cid=6EBB03E38A53ED3E&resid=6EBB03E38A53ED3E%21116&authkey=AC4lDqtLG8LqfiA.

  5. Feed it to wget using following syntax:

    wget --no-check-certificate "https://onedrive.live.com/download?cid=6EBB03E38A53ED3E&resid=6EBB03E38A53ED3E%21116&authkey=AC4lDqtLG8LqfiA"
    
  6. Enjoy.

  • Ok, now everything is in one place) – Fedorov7890 Feb 13 '17 at 21:58
  • One must not forget to put the link in "" in wget. I did and it didn't work. – Dushyant Bangal Mar 8 '17 at 9:58
  • @Fedorov7890 It doesn't work. I tried to download a folder. – Nikhil Sep 5 '18 at 9:13
  • It works for files only – Nikhil Sep 5 '18 at 9:31
4

Using Chrome (but Firefox will probably also work).

  1. Open DevTools
  2. Click the Download button.
  3. Download but cancel immediately
  4. Open the 'Network' tab in DevTools. Search for 'Zip?authKey=' in DevTools and open it (click). This is a POST request.
  5. Click 'View source' to the right of 'Form data' at the bottom.
  6. Construct the command as follows:

 

wget --post-data='<raw form data>' '<Download URL>'

Or:

wget --post-data='resIds=xxx&canary=yyy&authkey=zzz' 'https://cid--foobar.users.storage.live.com/downloadfiles/V1/Zip?authKey=zzz'

This even works on a different host (with a different IP address).

  • A simpler variation on this (using Firefox) is: Tools->Web Developer->Network. Find 'Zip?authKey=', right click on it and 'Copy as cURL'. Copy-paste into the command line and add '-o /path/to/some/file'. Of course this uses cURL instead of wget, but for this purpose they function identically – happyskeptic Dec 25 '17 at 4:41
2

This python SDK (with example) for OneDrive project works (for personal, business, and corporate accounts):

https://github.com/OneDrive/onedrive-sdk-python

1

Also, we can use CurlWget I already tried on OneDrive and Google Drive

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.