Pylons and Facebook
The following is my oauth template
top.location.href='https://graph.facebook.com/oauth/authorize?client_id=${config['facebook.appid']}&redirect_uri=${config['facebook.callbackurl']}&display=page&scope=publish_stream'; Click here to authorize this applicationWhen I hit the page I am prompted to login (desired), upon login I am redirected in a loop between a permissions page and an app page.
My controller looks like: class RootController(BaseController):
def __before__(self):
tmpl_context.user = None
if request.params.has_key('session'):
access_token = simplejson.loads(request.params['se开发者_开发问答ssion'])['access_token']
graph = facebook.GraphAPI(access_token)
tmpl_context.user = graph.get_object("me")
def index(self):
if not tmpl_context.user:
return render('/oauth_redirect.mako')
return render('/index.mako')
I'm guessing my settings are off somewhere, probably with the callback.
Not to sure if it is an issue with my code or the python sdk for facebook.
I think you should modify your code to look like this
def index(self):
if request.params.has_key('session'):
access_token = simplejson.loads(request.params['session'])['access_token']
graph = facebook.GraphAPI(access_token)
tmpl_context.user = graph.get_object("me")
return render('/index.mako')
return render('/oauth_redirect.mako')
and on your href url change redirect_uri to next and point it to your index view on your app
https://graph.facebook.com/oauth/authorize?client_id=${config['facebook.appid']}&next=/app/index&display=page&scope=publish_stream
精彩评论