Skip to content

Instantly share code, notes, and snippets.

@gdemir
Created April 16, 2015 12:04
Show Gist options
  • Save gdemir/6cdab7649bd45d8f01d1 to your computer and use it in GitHub Desktop.
Save gdemir/6cdab7649bd45d8f01d1 to your computer and use it in GitHub Desktop.
class FacebookGraphLoginHandler(tornado.web.RequestHandler, tornado.auth.FacebookGraphMixin):
@tornado.gen.coroutine
def get(self):
if self.get_argument("code", False):
user = yield self.get_authenticated_user(
redirect_uri='http://localhost:8888/facebook',
client_id=self.settings["facebook_api_key"],
client_secret=self.settings["facebook_secret"],
code=self.get_argument("code"))
# Save the user with e.g. set_secure_cookie
print user
else:
yield self.authorize_redirect(
redirect_uri='http://localhost:8888/facebook',
client_id=self.settings["facebook_api_key"],
extra_params={"scope": "read_stream,offline_access"})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment