I want to download a file from a SharePoint server (url).
I manage to download it using Firefox.
I can't manage to download it using
Sounds surprising, but the same URL works on Firefox, fails with curl.
Works on Firefox:
Actually, entering the URL initiates an authentication conversation between client and server, with in total 4 requests sent by Firefox:
- Initial request: The one I typed the URL into the browser:
https://mycorp.raxsp.com/_windows/default.aspx?ReturnUrl=/personal/mycorp_user1/_vti_bin/cmis/rest?getRepositories. It asked me for a user/password, so I entered it and validated. Response contains a
WWW-Authenticateheader with value
- Request 2: Same URL, but this time with an NTLM autorization token in the request headers.
- Request 3: Same, but this time the NTLM authorization token is the one found in the response header of request 2.
- Request 4: To
https://mycorp.raxsp.com/personal/mycorp_user1/_vti_bin/cmis/rest?getRepositories, download is successful.
Fails with curl:
With curl, the request below results in
curl -i -u firstname.lastname@example.org:mypass 'https://mycorp.raxsp.com/_windows/default.aspx?ReturnUrl=/personal/mycorp_user1/_vti_bin/cmis/rest?getRepositories'
Thinking I had to run the 4 requests like Firefox, I tried to add all 4 URLs to the curl command line, but that results in
401 Unauthorized for the first three and
403 FORBIDDEN for the last:
curl -i -u email@example.com:mypass 'url1' 'url2' 'url3' 'url4'
How to download the file without Firefox (from command-line)?
I am not limited to curl, any tool or programming language is fine too.