Here is an interesting behavior.
i have following function
@auth.requires_login()
@service.json
@service.jsonrpc
def acceptme():
return "accepted"
in this case, whatever username and password I give, I get returned
"accepted" but if I put @auth.requires_login() after @service.jsonrpc,
it always returns me "Object does not exist" .
I call it like this:
http://hasanatkazmi%40gmail.com:*****@localhost:8000/sahana/admin/call/json/acceptme
Anyone has an idea whats going on?
On Jun 4, 7:28 am, Alexei Vinidiktov <
alexei.v...@gmail.com>
wrote:
> I've tried this with the pyjamas tutorial and it didn't work. I've
> enabled user registration and registered a user whose credentials are
> used in the URL below. I got a server error when a function requiring
> user authentication was called.
>
> I changed the line
>
> JSONProxy.__init__(self, "../../default/call/jsonrpc", ["getTasks",
> "addTask","deleteTask"])
>
> to read
>
> JSONProxy.__init__(self,
> "
http://myemail%
40gmail.com%
3Amypa...@127.0.0.1:8000/pyjamas/defaul...",
> ["getTasks", "addTask","deleteTask"])
>
> What am I missing?
>
> Thanks.
>
>
>
> On Mon, Jun 1, 2009 at 12:51 PM, mdipierro <
mdip...@cs.depaul.edu> wrote:
>
> > OK. As you request since the latest version in trunk you can do
>
> > @auth.requires_login()
> > def index(): return 'hello world'
>
> > and access it with
>
> > curl -u username:passwordhttp://
127.0.0.1:8000/app/default/index
>
> > or
>
> > curlhttp://
username:pass...@127.0.0.1:8000/app/default/index
>
> > In the latter case username and password have to be encoded by
> > urllib.quote()
>
> > works for services too.
>
> > Massimo
>
> > On May 31, 10:43 pm, Dan <
danbr...@gmail.com> wrote:
> >> Since my last message on this thread, I came up with a patch to the
> >>Auth.login() code that lets me do what I need, so figured I should
> >> post it here. Let me know if you see any issues with this approach (or
> >> improvements to it).
>
> >> To recap, what I want to do is to let a script runing wget (not a
> >> browser)loginand then work with some parts of the app that require
> >> membership in groups. I want to pass the user's name and password to
> >> theloginformusing post variables in the URL. This is not normally
> >> possible with web2py'sAuth.login() function, so it needs to be
> >> 622 ifFORM.accepts(form, request.vars, session,
> >> 623 formname='login',
> >> 624 onvalidation=onvalidation):
>
> >> ... to be these 3 lines:
> >> if username in request.vars.keys() and request.vars.password and \
> >> FORM.accepts(form, request.vars,
> >> formname=None, onvalidation=onvalidation):
>
> >> This change lets theformtake the username and password from the
> >> URL's post variables (or theformitself - but not both of course).
> >> Then my script willloginusing wget's optional arguments "--keep-
> >> session-cookies --save-cookies=" when submitting the user name and
> >> password to the app'sloginfunction. These wget options store the
> >> session cookie in a local file. Then subsequent wget calls to the
> >> restricted parts of the app can use those cookies as a token to gain
> >> access with the option "--load-cookies=".
>
> >> Apologies for straying a bit from the original use case of this
> >> thread, but perhaps it's general approach will be a helpful hint.
>
> >> Also: I don't fully understand what the purpose of the "formname"
> >> parameter is, or why it was necessary to None-ify it. If someone can
> >> explain this to me, I'd appreciate it.
>
> >> Dan
>
> >> On May 29, 6:15 pm, Dan <
danbr...@gmail.com> wrote:
>
> >> > Reviving this thread from before... I would like to have a shell
> >> > script use wget to authenticate itself and access the data in a web2py
> >> > application, but I haven't been able to get the web2py app to accept
> >> > the post'ed email and password information, which I sent to the user/
> >> >loginURL. Is this the right way to do it?
> >> > "TheAuthcalls can be extended, personalized, and replaced by other
> >> > > > the lower level logic for authentication (like aloginfunction that
> >> > > > takes a username and a password). Any ideas on how I can do this.
> >> > > > I'm not afraid of writing my own implimentation, however I would love
> >> > > > to piggy back off what is already there.
>
> >> > > > I would figure I would want to have aloginfunction that would create