How can I instruct curl to reuse credentials after it followed a redirect?
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?
Solution 1:
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).