【发布时间】:2011-03-20 18:37:09
【问题描述】:
以下是我的oauth模板
top.location.href='https://graph.facebook.com/oauth/authorize?client_id=${config['facebook.appid']}&redirect_uri=${config['facebook.callbackurl']}&display=page&scope =发布流'; 单击此处授权此应用程序当我点击页面时,系统会提示我登录(需要),登录后我会在权限页面和应用页面之间的循环中重定向。
我的控制器看起来像: 类 RootController(BaseController):
def __before__(self):
tmpl_context.user = None
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")
def index(self):
if not tmpl_context.user:
return render('/oauth_redirect.mako')
return render('/index.mako')
我猜我的设置在某处关闭,可能与回调有关。
不确定这是否是我的代码或 facebook 的 python sdk 的问题。
【问题讨论】:
-
嗯,您要使用哪个流程?如果您使用的是“authorization_code”流程(或developers.facebook.com/docs/authentication 中记录的“服务器端”流程),您将丢失或在您的示例中遗漏了使用授权代码将用户重定向回来的部分,其中您的应用程序需要交换访问令牌。