Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

curl: provide user and password for apache .htaccess file

I am using cURL to test some RESTful APIs. Some of these APIs are served from an Apache machine, and protected with user/password combination using simple .httaccess files.

Is there a way to provide cURL with a username / password combination as arguments?

like image 588
Adam Matan Avatar asked Jan 28 '14 16:01

Adam Matan


2 Answers

Use this curl option for the commandline

-u "User:Password"

More details about this parameter can be found from here.

like image 126
Sabuj Hassan Avatar answered Nov 12 '22 17:11

Sabuj Hassan


You can use this curl command for example:

curl -A "Mozilla" -L 'http://user:password@localhost/api/someapi.php'
like image 4
anubhava Avatar answered Nov 12 '22 19:11

anubhava