Tomcat username and password2

M

Michael Oliver

Still trying to get python to access my local tomcat secured with the tomcat
realm

import urllib2


handler = urllib2.HTTPBasicAuthHandler()
handler.add_password(None,
'localhost:8080/manager/html', 'root', 'root')

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

try:
f = urllib2.urlopen( 'http://localhost:8080/manager/html' )
except urllib2.HTTPError, e:
if e.code == 401:
print 'not authorized'
elif e.code == 404:
print 'not found'
elif e.code == 503:
print 'service unavailable'
else:
print 'unknown error: '
else:
print 'success'
for line in f:
print line,


[Mike Oliver>>] this returns 'not authorized' no matter what I put in for
'realm' or 'host' to the add_password() method. I have tried None, 'tomcat'
for realm and 'localhost' and about every combination I can think of for
'host' if I go to that URL with a browser it asks for username and password
as above and that works. I can access it with code from PHP or Java just
fine.
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top