Facebook oauth

97 views
Skip to first unread message

Narendran

unread,
Aug 20, 2010, 2:07:43 PM8/20/10
to web2py-users
Hello all,
I picked the Facebook oauth submitted by mcm from
https://code.google.com/r/michelecomitini-facebookaccess/source/browse/gluon/contrib/login_methods/facebook_account.py
(referred in this thread:
http://groups.google.com/group/web2py/browse_thread/thread/be441047bf237f9/6ea33cf0d4bfba63?lnk=gst&q=facebook+oauth#6ea33cf0d4bfba63)

I am facing one isse:
1. I've placed require_login decoration on a method say a(). After the
authentication is complete, the page always gets redirected to default/
index, whereas the ideal behaviour would be to go to a(). It works as
intended if I use default auth instead of Facebook auth.

Also, is there any plugin/package that would provide full-fledged
support for using Facebook Graph API with web2py?

--
Thanks
Narendran

Michele Comitini

unread,
Aug 20, 2010, 3:33:30 PM8/20/10
to web...@googlegroups.com

Michele Comitini

unread,
Aug 21, 2010, 6:25:42 PM8/21/10
to web...@googlegroups.com, Massimo Di Pierro
Ok found a way to fix the problem with redirection (_next parameter).
Massimo pls look if the following is correct!


diff -r 9261ce4eda7f gluon/tools.py
--- a/gluon/tools.py Thu Aug 19 04:13:54 2010 +0200
+++ b/gluon/tools.py Sun Aug 22 00:08:25 2010 +0200
@@ -982,7 +983,7 @@
request = self.environment.request
args = request.args
if not args:
- redirect(self.url(args='login'))
+ redirect(self.url(args='login', vars=request.vars))
elif args[0] in self.settings.actions_disabled:
raise HTTP(404)
if args[0] == 'login':


2010/8/20 Michele Comitini <michele....@gmail.com>:

Michele Comitini

unread,
Aug 21, 2010, 6:37:25 PM8/21/10
to web...@googlegroups.com
in tools.py line 1436:
next = URL(r=request) + '?_next=' + next
should be like this?
next = self.url('user', args='login') + '?_next=' + next


2010/8/22 Michele Comitini <michele....@gmail.com>:

Michele Comitini

unread,
Aug 21, 2010, 7:10:58 PM8/21/10
to web...@googlegroups.com
Massimo here is the full patch with modifications for
oauth*_account.py login_methods

tnx!

2010/8/22 Michele Comitini <michele....@gmail.com>:

oauth_action_flow_fix.diff

Narendran

unread,
Aug 27, 2010, 12:40:04 AM8/27/10
to web2py-users
Hello Michele/Massimo,
Has this fix been taken in? Is it available in any web2py build now?

On Aug 22, 4:10 am, Michele Comitini <michele.comit...@gmail.com>
wrote:
> Massimo here is the full patch with modifications for
> oauth*_account.py login_methods
>
> tnx!
>
> 2010/8/22 Michele Comitini <michele.comit...@gmail.com>:
>
>
>
>
>
>
>
> > in tools.py line 1436:
> >                next = URL(r=request) + '?_next=' + next
> > should be like this?
> >                next = self.url('user', args='login') + '?_next=' + next
>
> > 2010/8/22 Michele Comitini <michele.comit...@gmail.com>:
> >> Ok found a way to fix the problem with redirection (_next parameter).
> >> Massimo pls look if the following is correct!
>
> >> diff -r 9261ce4eda7f gluon/tools.py
> >> --- a/gluon/tools.py    Thu Aug 19 04:13:54 2010 +0200
> >> +++ b/gluon/tools.py    Sun Aug 22 00:08:25 2010 +0200
> >> @@ -982,7 +983,7 @@
> >>         request = self.environment.request
> >>         args = request.args
> >>         if not args:
> >> -            redirect(self.url(args='login'))
> >> +            redirect(self.url(args='login', vars=request.vars))
> >>         elif args[0] in self.settings.actions_disabled:
> >>             raise HTTP(404)
> >>         if args[0] == 'login':
>
> >> 2010/8/20 Michele Comitini <michele.comit...@gmail.com>:
> >>> Hello Narendran,
>
> >>> Do not use that it is old..
>
> >>> now facebook is supported inside web2py distribution with oauth20_account.py
> >>> you can find an example app here:
> >>>http://code.google.com/r/michelecomitini-facebookaccess/source/browse...
>
> >>> for a simple example usage of graph api look here:
> >>>http://code.google.com/r/michelecomitini-facebookaccess/source/browse...
> >>>http://code.google.com/r/michelecomitini-facebookaccess/source/browse...
> >>>http://code.google.com/r/michelecomitini-facebookaccess/source/browse...
>
> >>> for the redirection after login I am investigating...
>
> >>> mic
>
> >>> 2010/8/20 Narendran <gunanar...@gmail.com>:
> >>>> Hello all,
> >>>> I picked the Facebook oauth submitted by mcm from
> >>>>https://code.google.com/r/michelecomitini-facebookaccess/source/brows...
> >>>>  (referred in this thread:
> >>>>http://groups.google.com/group/web2py/browse_thread/thread/be441047bf...)
>
> >>>> I am facing one isse:
> >>>> 1. I've placed require_login decoration on a method say a(). After the
> >>>> authentication is complete, the page always gets redirected to default/
> >>>> index, whereas the ideal behaviour would be to go to a(). It works as
> >>>> intended if I use default auth instead of Facebook auth.
>
> >>>> Also, is there any plugin/package that would provide full-fledged
> >>>> support for using Facebook Graph API with web2py?
>
> >>>> --
> >>>> Thanks
> >>>> Narendran
>
>
>
>  oauth_action_flow_fix.diff
> 17KViewDownload

mdipierro

unread,
Aug 27, 2010, 9:18:34 AM8/27/10
to web2py-users
I think so but I did not try it.

Michele Comitini

unread,
Aug 27, 2010, 1:27:00 PM8/27/10
to web...@googlegroups.com
The fixes have been applied, they are on trunk
http://code.google.com/p/web2py/source/checkout

they should work here is an updated version of the example app running on GAE:
http://grafbook.appspot.com/helloFacebook/graph

if it works it should mantain the url above even after authentication with fb.

mic

2010/8/27 mdipierro <mdip...@cs.depaul.edu>:

geoff

unread,
Sep 2, 2010, 11:35:22 AM9/2/10
to web...@googlegroups.com
Hi All.

This is my first foray into web2py. I am pretty comfortable with
python, but it's never been my primary language.

In any case I am building a Recipe database and UI for it which will
feed a number of different systems and allow non-tech users to add and
manipulate the recipes.

Since this is a publishing house the 'recipes' really have a lot more
associated with them than what you would generally assume thinking about
recipes.

This is replacing a shaky, older filemaker solution and a lot of the
data is thrown all over the place, and there are multiple tables that
are involved (nutrition information for example in a separate table) and
the import process is going to involve parsing/cleaning almost-csv files
and extracting information non-normalized data.

I guess this process should happen just at the python shell? Or map a
URL to a function maybe? This will likely be an iterative process with
some amount of wiping the db and going again.

Looking for any tips here. Also, is it appropriate to send code for
review into this list from time to time?

Thanks a lot
Geoff

Reply all
Reply to author
Forward
0 new messages