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?
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.
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 .
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.
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.
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With