Authentication session with urllib2
Ken Seehart
ken at seehart.com
Wed Nov 11 02:02:39 EST 2009
I'm having some difficulty implementing a client that needs to maintain
an authenticated https: session.
I'd like to avoid the approach of receiving a 401 and resubmit with
authentication, for two reasons:
1. I control the server, and it was easy for me to make a url that
receives a POST with username, password and authenticates the session.
The server keeps a session correctly when I test with a browser. This
part works fine.
2. I don't want to send every request twice. See
http://bugs.python.org/issue7159 There's no reason why I should have to
do this since I have the ability to keep the server simple.
What I would really like to do is send one request with the username and
password to establish the session, and then make multiple authenticated
requests where the session information remembers the authentication.
Is there a way to make this happen in python 2.5.2?
Keep in mind that this only needs to work with a particular server which
I control. It does not need to function as a general purpose browser.
The server is powered by Django.
- Ken
More information about the Python-list
mailing list