9

I know that curl can follow redirects (the -L argument), and I know that I can provide credentials to a request (-u username:password), but I want to use both all the way down the redirect chain.

How can I tell curl to reuse the username and password on every redirected location?

2
  • This would be useful to me..did you get a solution? Jul 7, 2015 at 10:31
  • Btw i discovered wget can do this, but still have not figured out how to do it with curl.. Jul 7, 2015 at 10:31

2 Answers 2

8

You can do this with the --location-trusted option:

allow sending the name + password to all hosts that the site may redirect to.

The libcurl option for this is CURLOPT_UNRESTRICTED_AUTH and it is available from curl version 7.10.4-pre6 (31 Mar 2003).

1
  • epic man curl overlook happened...
    – karatedog
    Dec 2, 2015 at 13:32
0

According to this post, http://curl.haxx.se/mail/archive-2008-11/0067.html, the --anyauth argument could be a solution.

1
  • 1
    I read this entry, but it is not the same problem. That HTTP request have multiple redirects,and one of those will ask for username and password,and asks if curl can use the provided credentials only when the webserver requests it. What I want is to instruct curl to use the credentials on every redirected URL. This might sound stupid, as there is no guarantee that every site uses the same credentials, but these sites are under my control and I set the same user/pass on them. (I am testing a desktop website, and wanted to check if it properly redirects if the UA is mobile)
    – karatedog
    Jul 3, 2015 at 20:05

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.