Dahua api auth? What's wrong?

EvgenioZ

Young grasshopper
Oct 31, 2016
48
0
Ukraine, Zaporozhye
Hi guys!

I'm trying to access Dahua API over wget/curl/php (file_get_contents) and receive auth error:
-----
[root@live02 ~]# wget -O- http://admin:password@1.2.3.4:80/cgi-bin/snapshot.cgi
--2017-07-24 13:42:28-- http://admin:*password*@1.2.3.4:80/cgi-bin/snapshot.cgi
Connecting to 1.2.3.4:80... connected.
HTTP request sent, awaiting response... 401 Unauthorized
Connecting to 1.2.3.4:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 45 [text/plain]
Saving to: `STDOUT'
0% [ ] 0 --.-K/s Error
ErrorID=0, Detail=Invalid Authority!
100%[=========================================================================================>] 45 --.-K/s in 0s

2017-07-24 13:42:28 (7.07 MB/s) - written to stdout [45/45]
-----

Option "-d" does nothing. But in browser all seems to be ok.

Any thoughts?

Thanks.
 
Some of the cameras have gone digest authentication rather than basic nowadays.

This could be your option depending how you're accessing the API
 
Last edited:
I've tried "-d" (digest option of wget) with no luck.
-------------------------

wget -O- -d http://admin:****@1.2.3.4:80/cgi-bin/snapshot.cgi
DEBUG output created by Wget 1.12 on linux-gnu.

--2017-07-25 10:30:37-- http://admin:*password*@1.2.3.4:80/cgi-bin/snapshot.cgi
Connecting to 1.2.3.4:80... connected.
Created socket 3.
Releasing 0x0000000001db1bb0 (new refcount 0).
Deleting unused 0x0000000001db1bb0.

---request begin---
GET /cgi-bin/snapshot.cgi HTTP/1.0
User-Agent: Wget/1.12 (linux-gnu)
Accept: */*
Host: 80.254.4.60:21080
Connection: Keep-Alive

---request end---
HTTP request sent, awaiting response...
---response begin---
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Digest realm="Login to 2MPAG9DM4A6A001",qop="auth",nonce="278146206",opaque="***"
Connection: close
CONTENT-LENGTH: 0

---response end---
401 Unauthorized
Closed fd 3
Connecting to 1.2.3.4:80... connected.
Created socket 3.
Releasing 0x0000000001db0250 (new refcount 0).
Deleting unused 0x0000000001db0250.

---request begin---
GET /cgi-bin/snapshot.cgi HTTP/1.0
User-Agent: Wget/1.12 (linux-gnu)
Accept: */*
Host: 80.254.4.60:21080
Connection: Keep-Alive
Authorization: Digest username="admin", realm="Login to 2MPAG9DM4A6A001", nonce="278146206", uri="/cgi-bin/snapshot.cgi", response="***", opaque="***"

---request end---
HTTP request sent, awaiting response...
---response begin---
HTTP/1.1 200 OK
Content-type: text/plain;charset=utf-8
CONNECTION: close
CONTENT-LENGTH: 45

---response end---
200 OK
Length: 45 [text/plain]
Saving to: `STDOUT'

0% [ ] 0 --.-K/s Error
ErrorID=0, Detail=Invalid Authority!
100%[=========================================================================================>] 45 --.-K/s in 0s

Closed fd 3
2017-07-25 10:30:38 (6.27 MB/s) - written to stdout [45/45]
 
I'm using wget 1.16 and it's working fine for me as well.