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_auth_http_client
def get_authenticated_user

Private Member Functions

def _on_access_token
def _on_facebook_request
def _on_get_user_info

Static Private Attributes

string _FACEBOOK_BASE_URL = "https://graph.facebook.com"
string _OAUTH_ACCESS_TOKEN_URL = "https://graph.facebook.com/oauth/access_token?"
string _OAUTH_AUTHORIZE_URL = "https://www.facebook.com/dialog/oauth?"
 _OAUTH_NO_CALLBACKS = False

Detailed Description

Facebook authentication using the new Graph API and OAuth2.

Definition at line 1265 of file auth.py.


Member Function Documentation

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

Definition at line 1312 of file auth.py.

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

Definition at line 1401 of file auth.py.

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

Definition at line 1332 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 `~OAuth2Mixin.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.gen.coroutine
def get(self):
    new_entry = yield self.facebook_request(
        "/me/feed",
        post_args={"message": "I am posting from my Tornado application!"},
        access_token=self.current_user["access_token"])

    if not new_entry:
        # Call failed; perhaps missing permission?
        yield self.authorize_redirect()
        return
    self.finish("Posted a message!")

The given path is relative to ``self._FACEBOOK_BASE_URL``,
by default "https://graph.facebook.com".

.. versionchanged:: 3.1
   Added the ability to override ``self._FACEBOOK_BASE_URL``.

Definition at line 1345 of file auth.py.

Returns the `.AsyncHTTPClient` instance to be used for auth requests.

May be overridden by subclasses to use an HTTP client other than
the default.

Definition at line 1409 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.gen.coroutine
      def get(self):
  if self.get_argument("code", False):
      user = yield 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"))
      # Save the user with e.g. set_secure_cookie
  else:
      yield self.authorize_redirect(
          redirect_uri='/auth/facebookgraph/',
          client_id=self.settings["facebook_api_key"],
          extra_params={"scope": "read_stream,offline_access"})

Definition at line 1273 of file auth.py.


Member Data Documentation

string tornado::auth.FacebookGraphMixin::_FACEBOOK_BASE_URL = "https://graph.facebook.com" [static, private]

Definition at line 1270 of file auth.py.

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

Definition at line 1267 of file auth.py.

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

Definition at line 1268 of file auth.py.

Definition at line 1269 of file auth.py.


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


rosbridge_server
Author(s): Jonathan Mace
autogenerated on Thu Aug 27 2015 14:50:40