Reese Knowledgebase

How to use curl to download files that use a cookie for authentication

View Kristian Reese's profile on LinkedIn


If you like this article, please +1 or Recommend via FB with the provided buttons above:

Article ID: 150
by: Reese K.
Posted: 05 Mar, 2014
Last updated: 05 Mar, 2014
Views: 3544

How to download files from sites requiring authentication

Have you ever logged into a website that requires you login before you can download a file?  Subsequently, a simple 'copy-link' option does not allow you to wget the file and a HTTP 403 Authorization Failed message is thrown.  In order to get around this, I've used this method when a cookie for authentication is used:

  1. If not installed, download and install Chrome
  2. Download and install cookie.txt export from the Chrome Web Store
  3. Using Chrome, login to the site where you're attempting to wget or curl a file for download.
  4. Click on the cookie.txt export button next to the address bar in Chrome, and copy the contents into a file, such as cookies.txt
  5. ~# curl -L -b cookies.txt http://authreq.com/todownload/thisfile.iso -o name.iso
    1. -L follow redirects; -b use the cookie in specified file; -o write ouput to this local file

Comments are welcome on alternative ways using other web browsers.

This article was:   Helpful | Not Helpful
Prev   Next
turning off auto indent and comments in vi     Linux

RSS