urllib2 auth error

R

rtilley

I get this error:

HTTP Error 401: Authorization Required

When I do this:

try:
handler = urllib2.HTTPBasicAuthHandler()
handler.add_password('realm', 'website', 'user', 'pass')
opener = urllib2.build_opener(handler)
urllib2.install_opener(opener)
f = urllib2.urlopen('http://website')
print f.read()
f.close()
except Exception, e:
print e

I have the right username and password. I may be using the above code
wrong. Any tips?

Thanks,
Brad
 

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,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top