Created
April 16, 2015 12:04
-
-
Save gdemir/6cdab7649bd45d8f01d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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