Dahua api auth? What's wrong?

EvgenioZ

Young grasshopper
Joined
Oct 31, 2016
Messages
48
Reaction score
0
Location
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.
 

psycik

Getting the hang of it
Joined
Dec 9, 2015
Messages
221
Reaction score
37
Location
Wellington, New Zealand
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:

EvgenioZ

Young grasshopper
Joined
Oct 31, 2016
Messages
48
Reaction score
0
Location
Ukraine, Zaporozhye
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]
 

aristobrat

IPCT Contributor
Joined
Dec 5, 2016
Messages
2,982
Reaction score
3,180
I'm using wget 1.16 and it's working fine for me as well.
 
Top