get_argument()中的Tornado OAuth2错误(Facebook更改)

时间:2017-04-03 09:16:00

标签: python-3.x tornado

我有一个问题,我无法解决。我的代码适用于localhost但是如何我有一个正确的域设置我有一些奇怪的问题试图登录Facebook。我已经转移到python 3.6

我有以下龙卷风设置代码:

for(i in seq_along(days)) {
  data[i,4] <- as.character(as.Date(data$MinEnrollmentDate, format="%d/%m/%Y")[i] + sample(1:days[i],1))
}

我无法弄清楚代码的结果。它显示:

  handlers = [
     (r"/facebookAuth",FBAuth),
     # other handlers...
  ]

  # Settings dict for Application
  settings = {
     # static handler 
     # Set specific HTTP404 errors to Error404 Class
     "default_handler_class": Error404,
     "cookie_secret":"xxx",
  "facebook_redirect_uri":"https://www.example.com/facebookAuth",
     "facebook_secret":"xxx",
     "facebook_app_id":"xxx",
  }


class FBAuth(BaseHandler,tornado.auth.FacebookGraphMixin):
  async def get(self):
      if self.get_argument("code", False):
          print("not code")
          user = await self.get_authenticated_user(redirect_uri=self.settings["facebook_redirect_uri"],
                                                   client_id=self.settings["facebook_app_id"],
                                                   client_secret=self.settings["facebook_secret"],
                                                   code=self.get_argument("code"))

          print("******")
          print(user)

          firstName=user["first_name"]
          lastName=user["last_name"]

          # set cookie and start up code

      else:
          print("code")
          await self.authorize_redirect(redirect_uri=self.settings["facebook_redirect_uri"],
                                        client_id=self.settings["facebook_app_id"],
                                        scope=["email","public_profile"])

并与以下内容崩溃:

code 
not code

似乎有一个问题:

调用get_authenticated_user()

中的

code = self.get_argument(“code”)

0 个答案:

没有答案