POST with basic auth and cookie from python?

Michael Foord fuzzyman at gmail.com
Sat Sep 4 20:20:27 CEST 2004


Lee Harr <missive at frontiernet.net> wrote in message news:<slrncjjdlh.f6.missive at homer.localdomain>...
> On 2004-09-04, Michael Foord <fuzzyman at gmail.com> wrote:
> > Dan Stromberg <strombrg at dcs.nac.uci.edu> wrote in message news:<pan.2004.09.03.20.30.52.790127 at dcs.nac.uci.edu>...
> >> If I wanted to write a python script that performs basic auth, gets a
> >> cookie, and then does an http POST using the cookie for authentication,
> >> what would be the best python API to write to?
> >> 
> >> Does someone already have example code that does something like this?
> >> 
>  
> > Oh - if anyone can help on this it would be great !! What the heck is
> > a realm and how do they work !!
> >
> >
> 
> 
> Not sure if this helps ...
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/267197

Thanks - it was the comments from that recipe that I got the code to
do basic athorization. One of the commenters also states that using
urllib2.HTTPPasswordMgrWithDefaultRealm will also do the job
(remembering the username and password for the realm, once you have
supplied it). The trouble is that in *my* code (sorry to the original
poster for hijacking the thread) is a CGI. This means that for each
seperate page access the process starts afresh - so I would need to
save in an external file the username and password combinations...
which is by no means an ideal solution.

The bottom line for me is that I don't actually understand what a
realm is and how http does authentication beyond the first page access
- does it need the username and password encoded in the headers for
access to every page in that realm ?

Tell you what - I'll start another thread and see if anyone
replies.....

Regards,

Fuzzy

http://www.voidspace.org.uk/atlantibots/pythonutils.html



More information about the Python-list mailing list