Authentication Examples?

Have some questions or having issues with your IP Camera(s), Post them here for the mods and other users to assist you with.
Post Reply
oppyoppy
Posts: 2
Joined: Wed Feb 21, 2018 8:35 pm

Authentication Examples?

Post by oppyoppy »

Hello All,

First time poster here.

I've been reading the CGI SDK API and am confused as to why there are no examples for the authentication topic. I'm a CGI noob, but IMHO the documentation shown below is not at all clear. What should be done to login to the camera via CGI? There are examples of all other functionality, but this topic got neglected.

Thanks in advance,

Oppy
The Amcrest video product supplies two authentication ways: basic authentication and digest authentication. If the http request does not have “Authorization”, the Amcrest video product returns a 401, until the http request has a legal authentication.
For example:
1. When basic authentication, the Amcrest video product response: 401 Unauthorized
WWW-Authenticate: Basic realm=”XXXXXX”
Then the client encode the username and password with base64, send the following request:
Authorization: Basic VXZVXZ.
2. When digest authentication, the Amcrest video product response:
WWW-Authenticate: Digest realm="DH_00408CA5EA04", nonce="000562fdY631973ef04f77a3ede7c1832ff48720ef95ad", stale=FALSE, qop="auth";
The client calculates the digest using username, password, nonce, realm and URI with MD5, then send the following request:
Authorization: Digest username="admin", realm="DH_00408CA5EA04", nc=00000001,cnonce="0a4f113b",qop="auth" nonce="000562fdY631973ef04f77a3ede7c1832ff48720ef95ad",uri="cgi-bin/global.login?userName=admin", response="65002de02df697e946b750590b44f8bf"
jantman
Posts: 33
Joined: Thu May 03, 2018 12:36 pm

Re: Authentication Examples?

Post by jantman »

What more examples are you looking for than the quote above?

With the asterisk that Basic is apparently no longer supported on newer firmware versions, only digest.
Principal Engineer, Tooling & Automation. Formerly, Wireless & Network Systems Engineer (among many other things).
Doing all sorts of crazy things to anything with an IP address.
http://www.jasonantman.com / http://github.com/jantman
jamestx10
Posts: 34
Joined: Fri Jul 15, 2016 7:36 am

Re: Authentication Examples?

Post by jamestx10 »

I am currently using

Code: Select all

<img src=http://USER:PW@CAMIP/cgi-bin/snapshot.cgi/ width= '1280'>
to pull an image. How do I make that same request using digest auth? Right now that code works every other time.
IP2M-841
tholius
Posts: 2
Joined: Mon May 08, 2017 3:51 pm

Re: Authentication Examples?

Post by tholius »

I have a similar question, because the http construct of user:pass@website is deprecated.
BlueSkyTrawler
Posts: 1
Joined: Tue Dec 07, 2021 9:32 am

Re: Authentication Examples?

Post by BlueSkyTrawler »

So here is what I used to get Digest Authentication Working in Python.

import requests
from requests.auth import HTTPDigestAuth

auth = HTTPDigestAuth ([username],[password])

#Move Right Command, note the auth added to the end.
r=requests.get('http://[cam ip]/cgi-bin/ptz.cgi?action=start&channel=0&code=Right&arg1=0&arg2=1&arg3=0',auth=auth)

After about a half second the camera will start panning to the right. To stop it you have to send another command with the action set to "stop".

later,
Bill
jantman
Posts: 33
Joined: Thu May 03, 2018 12:36 pm

Re: Authentication Examples?

Post by jantman »

What @BlueSkyTrawler said looks correct to m
jamestx10 wrote: Thu Nov 29, 2018 3:30 pm I am currently using

Code: Select all

<img src=http://USER:PW@CAMIP/cgi-bin/snapshot.cgi/ width= '1280'>
to pull an image. How do I make that same request using digest auth? Right now that code works every other time.
@jamestx10 and @tholius, unfortunately that's not possible. Using

Code: Select all

user:password@host
format in URLs, either in a browser address bar or in URLs inside a HTML page, only works for Basic authentication; it's not possible to use Digest credentials like this.
Principal Engineer, Tooling & Automation. Formerly, Wireless & Network Systems Engineer (among many other things).
Doing all sorts of crazy things to anything with an IP address.
http://www.jasonantman.com / http://github.com/jantman
User avatar
Revo2Maxx
Site Admin
Posts: 5820
Joined: Sat Jun 15, 2019 3:05 pm

Re: Authentication Examples?

Post by Revo2Maxx »

@jantman It all depends on the camera. I have a Old FW camera that it will work on so it really is FW related to what can and can't work. Maybe they are working in a older FW camera I just used it on my 751 over Wifi and it returned a picture
Screenshot (1604).png
Screenshot (1604).png (1.62 MiB) Viewed 1987 times
Here to help the best I can.
Be Safe
jantman
Posts: 33
Joined: Thu May 03, 2018 12:36 pm

Re: Authentication Examples?

Post by jantman »

@Revo2Maxx Oooohhh, you're right, sorry, I forgot that this wasn't mentioned explicitly in the thread:

HTTP Basic authentication (which works using the

Code: Select all

username:password@host
format in URLs, and is generally much simpler to work with) is considered insecure. A few years ago Amcrest updated the firmware to use Digest authentication instead, and thereby solve a security risk. Unfortunately, Digest authentication is much more difficult to work with... you can't just throw a username/password in a URL and have it work, and you can't just easily proxy or re-broadcast a stream.

If you have an older camera, or a camera still on the older firmware, you can just use Basic and have none of these issues.

I can't find the exact date/firmware version where the change was made, and it looks like the firmware download site no longer has a change log for... anything...
Principal Engineer, Tooling & Automation. Formerly, Wireless & Network Systems Engineer (among many other things).
Doing all sorts of crazy things to anything with an IP address.
http://www.jasonantman.com / http://github.com/jantman
User avatar
Revo2Maxx
Site Admin
Posts: 5820
Joined: Sat Jun 15, 2019 3:05 pm

Re: Authentication Examples?

Post by Revo2Maxx »

Yes funny thing is I have some other older cameras that it won't work on as well. Like my 850EB's and my 956EB, 846EB. While they do have older FW I am going to guess it was released after the issues and got the updated info that was needed to plug the hole. I know my 721ES, and my 751 both will work with the command. The 721ES I had to put on my normal network to test the command seeing it is normally behind my NVR on POE port. Now just gives me a reason to change out my 751. Don't really look at the feed much anyway just one of 4 cameras on my Driveway. The 721 is on its post because it has a Mic and have enough 841's and others that I could change it out but only on my Stairs so don't really matter much if it has higher then 720p output. Not broke don't fix it.. or in this case don't change it..
Here to help the best I can.
Be Safe
Post Reply