3

Just to give a background, our web application involves connecting to a network camera stream. Now the camera has an option for security, so we set up a password for its 'root' account. So whenever we connect to the web page, we see this prompt:

screenshot of the pop-up alert

I need an automatic authentication script or code, preferably Javascript, to solve this problem. I was trying to use XMLHttpObject.open() because the last two parameters that it asks is for username and password, and thought it might work but it's not working.

This is the code:

var xmlHttp = new XMLHttpRequest(); 
xmlHttp.open( "POST", "http://192.168.16.140/video.mjpg", true, "root", "password");
xmlHttp.send( null );

I also think this info might help you guys figure out what I wanted. I've created a C application prior to this web application that uses libcurl to connect to the said camera. Using

curl_easy_setopt(preset, CURLOPT_USERPWD, "username:password");

along with the other stuffs there I was able to connect to the camera and retrieve a screenshot. I want something similar to this, but preferably in Javascript form. I also want to understand how the libcurl command works.

I hope I can resolve this real soon and if there ever was a quick google search fix for this then I guess I'm not that much of a google ninja.

4
  • possible duplicate of Pure Javascript code for HTTP Basic Authentication? ...unless you're going to actually show the XHR.open() code that you tried, and explain what about it didn't work. Commented Nov 7, 2011 at 4:32
  • not working for me, and also not duplicate I think. I'll post an edit to the question. Commented Nov 9, 2011 at 1:25
  • Root password readable for everyone in a textfile? Commented Nov 9, 2011 at 5:59
  • yeah. It doesn't matter though, because the camera itself can't be accessed anyway, or so they say. The logic's not clear enough to me, they just want me to find a way to get rid of that dialog box. Commented Nov 9, 2011 at 8:02

1 Answer 1

1

I solved the problem, but I think this is not it. It is very unsafe. What I did was add the authentication to the URL:

http://user:pass@ipaddress/video.mjpg

On the src parameter of the img tag that I created. If anyone has an alternative solution please do give some. Thank you very much.

Sign up to request clarification or add additional context in comments.

1 Comment

There isn't a better way; if your authentication lives in client-sided code, there will always be a way to find out what it is.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.