basic_auth throwing 401 Unauthorized with Dahua IP camera

185 views
Skip to first unread message

Roman Gaufman

unread,
Jan 12, 2018, 10:44:10 AM1/12/18
to http.rb: a fast, easy-to-use Ruby HTTP client with a chainable API

I'm on Ubuntu linux, using Ruby 2.4.2p198 and http 3.0.0


When I try to make a connection to a Dahua camera, I get this:


> HttpClient.basic_auth(user: 'admin', pass: 'admin').get('http://192.168.1.108/cgi-bin/configManager.cgi?action=getConfig&name=General')
=> #<HTTP::Response/1.1 401 Unauthorized {"Www-Authenticate"=>"Digest realm=\"Login to 2L05ABCPAA00246\",qop=\"auth\",nonce=\"671353293\",opaque=\"f1f47336b1c3f6c079c49377096a6ed59f81806c\"", "Connection"=>"close", "Content-Length"=>"0"}>
>
> HttpClient.basic_auth(user: 'admin', pass: 'admin').get('http://admin:ad...@192.168.1.108/cgi-bin/configManager.cgi?action=getConfig&name=General')
=> #<HTTP::Response/1.1 401 Unauthorized {"Www-Authenticate"=>"Digest realm=\"Login to 2L05ABCPAA00246\",qop=\"auth\",nonce=\"2128627133\",opaque=\"f1f47336b1c3f6c079c49377096a6ed59f81806c\"", "Connection"=>"close", "Content-Length"=>"0"}>


However, wget works:

$ wget 'http://admin:ad...@192.168.1.108/cgi-bin/configManager.cgi?action=getConfig&name=General'
--2018-01-12 15:33:14--  http://admin:*password*@192.168.1.108/cgi-bin/configManager.cgi?action=getConfig&name=General
Connecting to 192.168.1.108:80... connected.
HTTP request sent, awaiting response... 401 Unauthorized
Authentication selected: Digest realm="Login to 2L05ABCPAA00246",qop="auth",nonce="665254639",opaque="f1f47336b1c3f6c079c49377096a6ed59f81806c"
Connecting to 192.168.1.108:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 207 [text/plain]
Saving to: ‘configManager.cgi?action=getConfig&name=General’

configManager.cgi?action=getConfig&name=General         100%[============================================================================================================================>]     207  --.-KB/s    in 0s

2018-01-12 15:33:14 (14.1 MB/s) - ‘configManager.cgi?action=getConfig&name=General’ saved [207/207]


Any ideas what I'm doing wrong?

Reply all
Reply to author
Forward
0 new messages