21

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?

Adam Matan
  • 128,757
  • 147
  • 397
  • 562

2 Answers2

39

Use this curl option for the commandline

-u "User:Password"

More details about this parameter can be found from here.

Sabuj Hassan
  • 38,281
  • 14
  • 75
  • 85
4

You can use this curl command for example:

curl -A "Mozilla" -L 'http://user:password@localhost/api/someapi.php'
anubhava
  • 761,203
  • 64
  • 569
  • 643