I used to use curl command in terminal to access a php web page to test some APIs in the web page. It works fine.
For example:
curl www.somesite.com -d parmetername=value
Now this page has basic http authentication. I knew I just need to add -u to give the username and password. I also googled and almost everyone suggests to do the same as following:
curl -u username:password www.somesite.com -d parmetername=value
curl --user username:password www.somesite.com -d parmetername=value
or
curl http://username:password@www.somesite.com -d parmetername=value
I have tried both of them, none of them works. I got the same error message as following:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>401 Authorization Required</title>
</head><body>
<h1>Authorization Required</h1>
<p>This server could not verify that you
are authorized to access the document
requested. Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn't understand how to supply
the credentials required.</p>
<p>Additionally, a 401 Authorization Required
error was encountered while trying to use an ErrorDocument to handle the request.</p>
<hr>
<address>Apache/2.2.29 (Unix) mod_ssl/2.2.29 OpenSSL/1.0.1e-fips mod_bwlimited/1.4 Server at www.somesite.com Port 80</address>
</body></html>
I have tried to access the website via browsers. After I typed in username and password in the prompt window. I can access to this website.
Does anyone know what's going on here? Thank you.