Digest Authentication, IP camera API Access.

Hi Everyone. First time poster here.

I have a hurdle to overcome involving Digest Authentication. I’m working on a project involving an ESP32, wifi router and a Dahua IP camera.

One of the things I’m trying to do is have the ESP32 connect to the IP Camera, and modify a text overlay in the video stream. I can do this without issue on a web browser by entering the following URL:

http://192.168.1.108/cgi-bin/configManager.cgi?action=setConfig&VideoWidget[0].CustomTitle[1].Text=Gates_Locked

Text=(whatever I want the overlay to say)

A sign in box appears, I enter my username and password, then I get text response in the window “OK” and the text overlay is updated.

I’m intending to call on a function in my program when conditions are met to toggle the text overlay between “Gates Locked” and “Gates Unlocked.” I have tried so far this method:

IPAddress ipCamera(192,168,1,108);

if (client.connect(ipCamera, 80)) {
Serial.println(“connected to IP CAM”);

client.println(“GET /cgi-bin/configManager.cgi?action=setConfig&VideoWidget[0].CustomTitle[1].Text=Gates Locked HTTP/1.1”);

client.println(“Connection: close”);
client.println();
}
else {
Serial.println(“connection failed”);
Serial.println();
}

while(client.connected() && !client.available()) delay(1); //waits for data
while (client.connected() || client.available()) { //connected or data available
char c = client.read();
Serial.print(c);
}

Serial.println();
Serial.println(“disconnecting.”);
Serial.println("==================");
Serial.println();
client.stop();
}

(I have yet to write the code which toggles the text variable) … anyway,

This is the response I get on the Serial Monitor:

connected to IP CAM
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Digest realm=“Login to 3J05EC2PAG00184”, qop=“auth”, nonce=“1642525586”, opaque=“5957a4b445349aee96110a92f24cb93cefd8da97”
Connection: close
Set-Cookie:secure; HttpOnly
CONTENT-LENGTH: 0

disconnecting.

I understand this has something to do with the authentication, obviously there is no sign in window to enter the credentials in because this isn’t happening in a GUI… so how do I proceed? I’m assuming whatever code I need has to be placed in the function just after my GET request. I have tried adding my username and password into the request like admin:password@192.168.1.108/ etc. but that yields nothing different. Thanks in advance.

here I have a http request with digest auth.

esp32 may have better options

Juraj:
here I have a http request with digest auth.
Regulator/SusCalib.ino at master · jandrassy/Regulator · GitHub
esp32 may have better options

Thankyou Juraj! I will have a look and see if I can get my head around that :slight_smile:

peppy_hare:
Thankyou Juraj! I will have a look and see if I can get my head around that :slight_smile:

read the at least the wikipedia page about digest auth