Re: how to write our own handler to handle login in cherryPY

"Joseph S. Tate" <[email protected]>
Newsgroups gmane.comp.python.cherrypy
Message-ID <CA+WDQbHVLGUj8NF5BJQMN++Vze6ankuDJSw9HLD1J+pUVw+HtQ@mail.gmail.com>
You shouldn't have to "mechanize" to post your credentials. You should just
be able to httplib2.post(), unless there's some sort of captcha system.

You need to capture the session cookie that returns though, and use that on
all subsequent requests.

On Tue, Apr 26, 2016 at 7:49 AM Michiel Overtoom <motoom-qWit8jRvyhVmR6Xm/[email protected]> wrote:

> Hi Dharmendra,
>
> > On 2016-04-26, at 13:06, Dharmendra Shaw <[email protected]>
> wrote:
> >
> > For authentication we are using "tools.session_auth"
> > I have a need to support login to app using REST API
>
> I have a similar setup.
>
> To have an external script log in as if it were a real user using a
> webbrowser, I use 'mechanize':
>
>     import mechanize
>     br = mechanize.Browser()
>     response = br.open("http://www.myserver.com/login")
>     br.form = list(br.forms())[0]
>     control = br.form.find_control("username")
>     control.value = "MY_NAME"
>     control = br.form.find_control("password")
>     control.value = "MY_SECRET_PASSWORD"
>     response = br.submit()
>
> ...and after that I can request pages:
>
>     response = br.open("http://www.myserver.com/api/item?id=12", "")
>     body = response.read()
>     response.close()
>     j = json.loads(body)
>
> I'm not sure if this is anything like you need, but maybe you get some
> ideas from it.
>
> Greetings,
>
> --
> You received this message because you are subscribed to the Google Groups
> "cherrypy-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
> To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
> Visit this group at https://groups.google.com/group/cherrypy-users.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.