Pass user/pass to curl from a local file

85 Views Asked by At

I know that you can give cURL a user/pass combination using the -u flag which is great. What I'm trying to do is get the credentials from a file on the filesystem and pass that in. For example

in auth.conf

id=q8374grf748
key=47w34kurgfuegurfgser7348gfeurfgyu

then I'd like to do the equivalent:

curl -u id:key http://example.com
1

There are 1 best solutions below

0
On

You can Try this out :-

curl --user user:pass https://whatever.com/login

Even if you need to save cookie and try to access another page in site try this

first

curl --user user:pass --cookie-jar ./cookiefile https://whatever.com/login

Second

curl --cookie ./cookiefile https://whatever.com/secondpage