Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing basic http authenticaation with digest using curl

How can we test authentication with digest as explained here using curl?

I am able to test Simple Basic example by setting Authorization header to Basic {SECRET} where SECRET is Base64::encode64("username:password") as explained here

I tried sending Authentication header with same value but getting NoMethodError (undefined method 'unpack' for nil:NilClass) on line having call authenticate_or_request_with_http_digest

Would anyone please explain what I am doing wrong here?

like image 775
Amit Patel Avatar asked Sep 10 '12 12:09

Amit Patel


People also ask

How do I use basic authentication with curl?

To use basic authentication, use the cURL --user option followed by your company name and user name as the value. cURL will then prompt you for your password.

How do you test basic authentication?

Testing Basic Auth with httpbinThe endpoint for Basic Auth is /basic-auth/{user}/{passwd} . For example, if you go to http://httpbin.org/basic-auth/foo/bar you'll see a prompt and you can authenticate using the username foo and the password bar .

How can I pass the basic HTTP authentication?

We can do HTTP basic authentication URL with @ in password. We have to pass the credentials appended with the URL. The username and password must be added with the format − https://username:password@URL.

How do I pass login credentials with curl?

For example, if a website has protected content curl allows you to pass authentication credentials. To do so use the following syntax: curl --user "USERNAME:PASSWORD" https://www.domain.com . “USERNAME” must be replaced with your actual username in quotes.


1 Answers

Finally I am able to fix the problem. Here is how I used curl to test http basic authentication with digest

curl --data {"red":"00"} --digest -u "username:password" "http://localhost:3000/api/statistics"
like image 113
Amit Patel Avatar answered Nov 09 '22 20:11

Amit Patel