
Public Member Functions | |
| def | facebook_request |
| def | get_authenticated_user |
Private Member Functions | |
| def | _on_access_token |
| def | _on_facebook_request |
| def | _on_get_user_info |
Static Private Attributes | |
| string | _OAUTH_ACCESS_TOKEN_URL = "https://graph.facebook.com/oauth/access_token?" |
| string | _OAUTH_AUTHORIZE_URL = "https://graph.facebook.com/oauth/authorize?" |
| _OAUTH_NO_CALLBACKS = False | |
| def tornado.auth.FacebookGraphMixin._on_access_token | ( | self, | |
| redirect_uri, | |||
| client_id, | |||
| client_secret, | |||
| callback, | |||
| fields, | |||
| response | |||
| ) | [private] |
| def tornado.auth.FacebookGraphMixin._on_facebook_request | ( | self, | |
| callback, | |||
| response | |||
| ) | [private] |
| def tornado.auth.FacebookGraphMixin._on_get_user_info | ( | self, | |
| callback, | |||
| session, | |||
| fields, | |||
| user | |||
| ) | [private] |
| def tornado.auth.FacebookGraphMixin.facebook_request | ( | self, | |
| path, | |||
| callback, | |||
access_token = None, |
|||
post_args = None, |
|||
| args | |||
| ) |
Fetches the given relative API path, e.g., "/btaylor/picture"
If the request is a POST, post_args should be provided. Query
string arguments should be given as keyword arguments.
An introduction to the Facebook Graph API can be found at
http://developers.facebook.com/docs/api
Many methods require an OAuth access token which you can obtain
through authorize_redirect() and get_authenticated_user(). The
user returned through that process includes an 'access_token'
attribute that can be used to make authenticated requests via
this method. Example usage::
class MainHandler(tornado.web.RequestHandler,
tornado.auth.FacebookGraphMixin):
@tornado.web.authenticated
@tornado.web.asynchronous
def get(self):
self.facebook_request(
"/me/feed",
post_args={"message": "I am posting from my Tornado application!"},
access_token=self.current_user["access_token"],
callback=self.async_callback(self._on_post))
def _on_post(self, new_entry):
if not new_entry:
# Call failed; perhaps missing permission?
self.authorize_redirect()
return
self.finish("Posted a message!")
| def tornado.auth.FacebookGraphMixin.get_authenticated_user | ( | self, | |
| redirect_uri, | |||
| client_id, | |||
| client_secret, | |||
| code, | |||
| callback, | |||
extra_fields = None |
|||
| ) |
Handles the login for the Facebook user, returning a user object.
Example usage::
class FacebookGraphLoginHandler(LoginHandler, tornado.auth.FacebookGraphMixin):
@tornado.web.asynchronous
def get(self):
if self.get_argument("code", False):
self.get_authenticated_user(
redirect_uri='/auth/facebookgraph/',
client_id=self.settings["facebook_api_key"],
client_secret=self.settings["facebook_secret"],
code=self.get_argument("code"),
callback=self.async_callback(
self._on_login))
return
self.authorize_redirect(redirect_uri='/auth/facebookgraph/',
client_id=self.settings["facebook_api_key"],
extra_params={"scope": "read_stream,offline_access"})
def _on_login(self, user):
logging.error(user)
self.finish()
string tornado::auth.FacebookGraphMixin::_OAUTH_ACCESS_TOKEN_URL = "https://graph.facebook.com/oauth/access_token?" [static, private] |
string tornado::auth.FacebookGraphMixin::_OAUTH_AUTHORIZE_URL = "https://graph.facebook.com/oauth/authorize?" [static, private] |
tornado::auth.FacebookGraphMixin::_OAUTH_NO_CALLBACKS = False [static, private] |