Web authentication
John J. Lee
jjl at pobox.com
Thu Dec 4 18:45:23 EST 2003
Paul Rubin <http://phr.cx@NOSPAM.invalid> writes:
> "luigipaioro" <luigipaioro at libero.it> writes:
> > Does anybody know how can I acces to my site with authentication?
> >
> > I think that urllib2 can help me but I don't undestand how!!!
>
> It's documented in the manual. Try something like (untested):
>
> import urllib
>
> class Open_with_auth(urllib.FancyURLopener):
> def prompt_user_passwd(self, host, realm):
> return ('username', 'userpassword') # the uid and passwd you want to use
>
> urllib._urlopener = Open_with_auth()
Doesn't/shouldn't http://user:passwd@example.com/blah.html work?
I don't know where that syntax is specified (if anywhere) -- do you
know, Paul? It seems at a glance that urllib understands that syntax
for ordinary Basic Auth., where urlib2 only knows it as a syntax for
proxy Basic Auth., but I may be wrong there...
John
More information about the Python-list
mailing list