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?

Answers


Use this curl option for the commandline

-u "User:Password"

More details about this parameter can be found from here.


You can use this curl command for example:

curl -A "Mozilla" -L 'http://user:password@localhost/api/someapi.php'

Need Your Help

How can I beta test web Perl modules under Apache/mod_perl on production web server?

perl apache testing mod-perl perl-module

We have a setup where most code, before being promoted to full production, is deployed in BETA mode - meaning, it runs in full production environment (using production database - usually production...

C programming Reading a specific line of a text file

c file

So i've been given an exercise to work on: Have the user input a number and the program will display the line of text associated with that line for example