Re: how to write our own handler to handle login in cherryPY
Michiel Overtoom <motoom-qWit8jRvyhVmR6Xm/[email protected]>
| Newsgroups | gmane.comp.python.cherrypy |
|---|---|
| Message-ID | <[email protected]> |
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.