Public Member Functions | Private Member Functions | Static Private Attributes
tornado.auth.FacebookGraphMixin Class Reference
Inheritance diagram for tornado.auth.FacebookGraphMixin:
Inheritance graph
[legend]

List of all members.

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

Detailed Description

Facebook authentication using the new Graph API and OAuth2.

Definition at line 949 of file auth.py.


Member Function Documentation

def tornado.auth.FacebookGraphMixin._on_access_token (   self,
  redirect_uri,
  client_id,
  client_secret,
  callback,
  fields,
  response 
) [private]

Definition at line 999 of file auth.py.

def tornado.auth.FacebookGraphMixin._on_facebook_request (   self,
  callback,
  response 
) [private]

Definition at line 1083 of file auth.py.

def tornado.auth.FacebookGraphMixin._on_get_user_info (   self,
  callback,
  session,
  fields,
  user 
) [private]

Definition at line 1020 of file auth.py.

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!")

Definition at line 1032 of file auth.py.

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()

Definition at line 955 of file auth.py.


Member Data Documentation

string tornado::auth.FacebookGraphMixin::_OAUTH_ACCESS_TOKEN_URL = "https://graph.facebook.com/oauth/access_token?" [static, private]

Definition at line 951 of file auth.py.

string tornado::auth.FacebookGraphMixin::_OAUTH_AUTHORIZE_URL = "https://graph.facebook.com/oauth/authorize?" [static, private]

Definition at line 952 of file auth.py.

Definition at line 953 of file auth.py.


The documentation for this class was generated from the following file:


roswww
Author(s): Jonathan Mace
autogenerated on Thu Jan 2 2014 11:53:30