Authenticate with HTTP Digest auth
https://api.testingapis.com/api/auth/digestAuthenticate with HTTP Digest auth (MD5, qop=auth).
Credentials: apibee / password123, realm apibee. A request without credentials gets 401 with a WWW-Authenticate: Digest challenge carrying nonce and opaque; clients such as curl --digest, Postman and requests.auth.HTTPDigestAuth then retry automatically.
response = MD5(HA1:nonce:nc:cnonce:qop:HA2) where HA1 = MD5(username:realm:password) and HA2 = MD5(method:uri). Without qop: MD5(HA1:nonce:HA2). Nonces expire after 5 minutes; the 401 then includes stale=true. Replays are refused: with qop=auth each request must use a higher nc than the last one for that nonce, and without qop a nonce works once.
Note: HTTP Digest (RFC 7616, MD5, qop=auth). First call returns 401 with a nonce; curl --digest / Postman handle the handshake.
HTTP Digest (MD5, qop=auth) — apibee / password123
Responses
- 200
- Authenticated.
- 401
- Missing or invalid Digest header, wrong credentials, or an unknown or stale nonce. Includes a fresh challenge.
Example
curl -X GET "https://api.testingapis.com/api/auth/digest" \
--digest -u apibee:password123{"authenticated": true, "scheme": "digest", "user": "apibee", "qop": "auth"}Code examples
const response = await fetch("https://api.testingapis.com/api/auth/digest", {
headers: {
"Authorization": "Basic YXBpYmVlOnBhc3N3b3JkMTIz",
},
});
console.log(response.status, await response.text());import requests
response = requests.request(
"GET",
"https://api.testingapis.com/api/auth/digest",
auth=("apibee", "password123"),
allow_redirects=False,
)
print(response.status_code, response.text)import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newBuilder()
.followRedirects(HttpClient.Redirect.NEVER)
.build();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.testingapis.com/api/auth/digest"))
.header("Authorization", "Basic YXBpYmVlOnBhc3N3b3JkMTIz")
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
}
}