Ip Camera Password

Posted on
Wed Aug 21, 2013 9:45 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Ip Camera Password

How about user=indigo password=access. Still fails.

Posted on
Wed Aug 21, 2013 10:07 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Ip Camera Password

I added one line of code to the request handler to get it to throw an exception and give some debug data.

In case this might be useful, here is what I got:

Code: Select all
Exception: "DEBUG...http://indigo:access@192.168.5.37/IMAGE.JPG...

  WebServer                       internal server error "http://127.0.0.1:8176/refreshingimage" from 127.0.0.1
  WebServer                       

Request Headers:
  AUTHORIZATION: Digest username="********", realm="Indigo Control Server", nonce="4c62e206ac05e04eb77c0fc4e15247fb", uri="/refreshingimage?page=control%20page%20copy&id=0&nocache=1377101008393", response="1f3769b8515fa44b78e686f6e0ab00bf", algorithm="MD5", cnonce="14ce3ea04ff917459312bfbc799b80f4", nc=00000070, qop="auth"
  REFERER: http://127.0.0.1:8176/controlpage?name=control%20page%20copy
  HOST: 127.0.0.1:8176
  ACCEPT: */*
  USER-AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/536.30.1 (KHTML, like Gecko) Version/6.0.5 Safari/536.30.1
  CONNECTION: keep-alive
  Remote-Addr: 127.0.0.1
  ACCEPT-LANGUAGE: en-us
  ACCEPT-ENCODING: gzip, deflate

Posted on
Thu Aug 22, 2013 6:42 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Ip Camera Password

This appears to be a Python issue. I tried the basic urllib2 connection in a standalone script
Code: Select all
import urllib2
from urllib2 import Request, urlopen, URLError

address = "192.168.5.37"
port = "80"
user = "indigo"
passw = "access"

theUrl = "http://" + address + ":" +  port + "/IMAGE.JPG"
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
password_mgr.add_password(None, theUrl, user, passw)
handler = urllib2.HTTPBasicAuthHandler(password_mgr)

opener = urllib2.build_opener(handler)
urllib2.install_opener(opener)

try:
    req = urllib2.Request(theUrl)
    response = urllib2.urlopen(req)
    the_page = response.read()   
except URLError, e:
    if hasattr(e, 'reason'):
        print ("Failed to reach camera  at %s. Reason = %s" % (address, e))
    elif hasattr(e, 'code'):
        print ("The camera at \"%s\" could not fulfill the request. Reason = %s" % (address, e))           

and got the same 401 Error.

Then I tried a script which I found on this site. The poster was having the same issue we are experiencing:
Code: Select all
# TestAuthHandler.py
import base64, httplib, urllib2
httplib.HTTPConnection.debuglevel = 1
#
def TestAuth(method):
    data = {'prot':'http','user':'indigo','pass':'access','host':'192.168.5.37','port':'80','path':'IMAGE.JPG','realm':None}
    url = '%(prot)s://%(host)s:%(port)s/%(path)s' % data
    req = urllib2.Request(url)
#
    if (method == 'headers'):
        base64string = base64.encodestring('%s:%s' % (data['user'], data['pass']))[:-1]
        req.add_header("Authorization", "Basic %s" % base64string)
    elif (method == 'handler'):
        auth_url = '%(host)s:%(port)s/%(path)s' % data
        auth_handler = urllib2.HTTPBasicAuthHandler()
        auth_handler.add_password(data['realm'], auth_url, data['user'], data['pass'])
        opener = urllib2.build_opener(auth_handler)
        urllib2.install_opener(opener)
        #
    f = urllib2.urlopen(req)
    data = f.read()
    print repr('%s' % data)

TestAuth('headers')
TestAuth('handler')
It works when called with 'headers' but fails when called with 'handler.'

Posted on
Thu Aug 22, 2013 1:36 pm
matt (support) offline
Site Admin
User avatar
Posts: 21416
Joined: Jan 27, 2003
Location: Texas

Re: Ip Camera Password

Interesting. I've have a new replacement version of indigoreqhandler.py to try. After you stop and restart the Indigo Server, open your Control Page and change the control to have a URL like this:

Code: Select all
http://forcebasic:username:password@pageUrl


The forcebasic will tell the IndigoWebServer to stuff the username/password directly into the header as a workaround. Note the Control Page editor won't show the image since the forcebasic flag isn't understood by the Indigo GUI client, but I can tweak that in the next release of 6.0 to filter it out.

Let me know if it works, and thanks for tracking down a workaround.

Image

Posted on
Thu Aug 22, 2013 2:48 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Ip Camera Password

Bingo! That got it. Thanks. I guess there is a bug (or very poor documentation) in Basic Auth in urllib2.

Posted on
Fri Aug 23, 2013 7:07 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Ip Camera Password

Matt: I have a suggestion for the Control Page image URL UI.

Rather than include the "force basic" command as a pseudo part of the URL, you could add the following widgets:

A radio button option to select the source: Local file HTTP Protocol
A Username text field
A Password text field
a check box to: Include authentication information in the URL (http://user:password@... )
a check box to: Force basic authentication mode
Ideally, the Force basic authentication check box's appearance would be conditional on the Include auth information in URL option being selected.

Then, the "URL" text field would just include the local file path or the remote host[:port] & path
This would simplify the data parsing to create the urllib2 url and be a little less confusing to the user.

But, of course, UI development has its own price and this is a pretty obscure function. So, I'm not really pushing very hard for this.

Posted on
Fri Aug 23, 2013 8:44 am
matt (support) offline
Site Admin
User avatar
Posts: 21416
Joined: Jan 27, 2003
Location: Texas

Re: Ip Camera Password

Agreed that would be a better approach, but for now we'll probably just keep everything encoded in the URL. Thanks for the feedback.

Image

Who is online

Users browsing this forum: No registered users and 5 guests