urllib2 authentication problems!

Anand B Pillai abpillai at lycos.com
Fri Mar 7 10:46:08 EST 2003


Hi
  I am using urllib2 in my application to open a url which needs
validation
using https username/password. I am using python 2.2.1 on Windows nt
4.0.

 My code is as follows...
 
 
 authinfo=urllib2.HTTPBasicAuthHandler()
 authinfo.add_password('realm', 'myurl', 'myusername', 'mypasswd')
 opener=urllib2.build_opener(authinfo, urllib2.HTTPHandler)

 urllib2.install_opener(opener)
 try:
    streamdata=urllib2.urlopen(myurl).read()
 except urllib2.URLError, e:
    msg=str(e)
    msg+='!\n\n'
    msg+="Check the URL"
    print msg

It always prints the error message 
"
<urlopen error unknown url type: https>!

Check the URL"

 The validation for the realm I am requesting is done through https
and not http. What is the mistake I am making here. I cannot
understand the error message since I thought that python 2.1 upwards
had builtin https url support.

Anand Pillai
http://members.fortunecity.com/anandpillai




More information about the Python-list mailing list