How to access protect folder by apache HTTP Basic Authentication using cURL

Normally if you try to access protect folder by Basic Authentication without proper credentials you will get 401 Unauthorized error:

Example:

curl -s https://yourwebserver.com/mysecure

<!DOCTYPE HTML PUBLIC “-//IETF//DTD HTML 2.0//EN”>
<html><head>
<title>401 Unauthorized</title>
</head><body>
<h1>Unauthorized</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>
</body></html>

You need to specify your username and password to get this passed:

Example:

curl --user admin:yoursecurepassword -s https://yourwebserver.com/mysecure

Enjoy!

Similar Posts:

2 comments on “How to access protect folder by apache HTTP Basic Authentication using cURL

  1. я сьогодні переглядав в Інтернеті більше 4 годин, але жодної цікавої статті, подібної до вашої, я так і не знайшов.
    А це досить цінно для мене. На мій погляд, якщо всі власники сайтів та
    блогери будуть створювати хороший контент, як і
    ви, інтернет буде набагато кориснішою, ніж будь-коли раніше.

Leave a Reply to Леся Cancel reply

Your email address will not be published. Required fields are marked *