2
votes

How would one setup curl digest auth in postman?

Eg curl command:

curl -vL --digest --user mike:pwd -X POST --data 'hello' 'localhost:3000/duh'

I tried using digest authentication as well as basic authentication in Postman. Digest auth returned 401 whereas basic auth returned 500. So I'd say basic authentication is not the right one.

In digest auth, I set the following options.

Username: mike
Realm: {{echo_digest_realm}} 
Password: pwd
Nonce: {{echo_digest_nonce}} 

Everything else kept at default. I also checked the 'Save helper data to request' checkbox and Update Request button.

Still getting a 401.

According to the response, I'm getting a nonce, realm and also a qop. I didn't set this in the digest auth parameter before but decided to set it manually since it doesn't change per request. Still nothing.

1

1 Answers

1
votes

{{echo_digest_*}} is a variable of Postman-Echo I known.

It seems that Postman doesn't support a digest authentication automatically.
This requirement is still open, you can check here.
So that, Postman's member suggests to use "Pre-request script" or "Tests" on the similar issue(/issues/2626).

And finally, some guy shows us the work-around like below. postmanlab GitHub

var regEx = /nonce="(.*==)"/;  
var arr = regEx.exec(wwwAuth);  
if (arr && arr.length > 1) {  
  var nonce = arr[1];  
  postman.setEnvironmentVariable("echo_digest_nonce", nonce);  
}

You might to change the regular expression like /nonce="(.*?)"/.

I hope it will help you.