Authentication session with urllib2

K

Ken Seehart

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
 
J

Jon Clements

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.  Seehttp://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

How about http://docs.djangoproject.com/en/dev/topics/auth/ and using
a urllib2 opener with cookie support ala some examples on
http://personalpages.tds.net/~kent37/kk/00010.html ?

hth,
Jon.
 

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,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top