I need to do the same thing and have not found a solution. I would love to 
know if someone has a script that works.

As for Richard's script and Massimo's reply, I have the following questions:

1. Will Richard's script work if the value of "_formkey" is extracted from 
the login page?

2. What does Massimo mean by "If you accept(request.vars, formname=None)"? 
Is it a setting that I can add in a specific file?

Many thanks in advance.

Ke 

On Friday, August 14, 2009 12:57:03 AM UTC-7, mdipierro wrote:
>
> The _formkey they you send has to be the same you receive. 
>
> If you accept(request.vars,formname=None) 
>
> without passing a session there is no _formkey, no _formname and no 
> worry about it. 
>
> Massimo 
>
> On Aug 14, 2:52 am, Richard <[email protected]> wrote: 
> > hello, 
> > 
> > I want to automate some interaction with my web2py application web 
> > interface but am having trouble logging in. 
> > I am using the builtin auth login form. 
> > Has anyone succeeded in building such a script, or can see what is 
> > wrong with my script below? 
> > 
> > import urllib 
> > import urllib2 
> > import cookielib 
> > 
> > cj = cookielib.LWPCookieJar() # use cookies 
> > opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) 
> > post_data = urllib.urlencode({'email': email, 'password': password, 
> > '_formkey': '435ds2a5-3427-4d8f-45b9-0b5da0453351'}) 
> > request = urllib2.Request(login_url, post_data) 
> > response = opener.open(request) 
> > 
> > Some thoughts: 
> > - is a formkey necessary, and does it need to be unique? 
> > - do I need to use multipart encoded data? (which Python's builtin 
> > libraries do not support) 
> > 
> > thanks, 
> > Richard

Reply via email to