Problem with urllib2 and authentification


M

Miguel Beltran R.

Using this script for connect to Zope I have this error

---script:
import urllib2

protocolo='http://'
servidor='10.28.1.239/'
pagina='manage'
fullurl=protocolo+servidor+pagina

aut=urllib2.HTTPBasicAuthHandler()
aut.add_password(realm=None,
uri=servidor,
user='myadmin',
passwd='mypass')
opener=urllib2.build_opener(aut, urllib2.HTTPHandler(debuglevel=1))

print opener.open(fullurl).read()


---Error:
connect: (10.28.1.239, 80)
send: 'GET /manage HTTP/1.1\r\nAccept-Encoding: identity\r\nHost:
10.28.1.239\r\nConnection: close\r\nUser-agent:
Python-urllib/2.4\r\n\r\n'
reply: 'HTTP/1.1 401 Unauthorized\r\n'
header: Server: Zope/(Zope 2.10.5-final, python 2.4.4, win32) ZServer/1.1
header: Date: Tue, 22 Apr 2008 14:14:45 GMT
header: Bobo-Exception-Line: 713
header: Content-Length: 884
header: Bobo-Exception-Value: See the server error log for details
header: Content-Type: text/html; charset=iso-8859-15
header: Bobo-Exception-Type: Unauthorized
header: Connection: close
header: Bobo-Exception-File: HTTPResponse.py
header: WWW-Authenticate: basic realm="Zope"
Traceback (most recent call last):
File "z.py", line 15, in ?
print opener.open(fullurl).read()
File "/usr/local/lib/python2.4/urllib2.py", line 364, in open
response = meth(req, response)
File "/usr/local/lib/python2.4/urllib2.py", line 471, in http_response
response = self.parent.error(
File "/usr/local/lib/python2.4/urllib2.py", line 402, in error
return self._call_chain(*args)
File "/usr/local/lib/python2.4/urllib2.py", line 337, in _call_chain
result = func(*args)
File "/usr/local/lib/python2.4/urllib2.py", line 480, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 401: Unauthorized

why not send authentification?

I try python 2.5 on slackware 12
too on python 2.4 and 2.5 on windows xp

All same error
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top