class_docstr: Facebook authentication using the new Graph API and OAuth2.
class_docstr_tok: ["Facebook","authentication","using","the","new","Graph","API","and","OAuth2","."]
docstr: 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:
  
  ..testcode::
  
      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!")
  
  .. testoutput::
     :hide:
  
  The given path is relative to ``self._FACEBOOK_BASE_URL``,
  by default "https://graph.facebook.com".
  
  This method is a wrapper around `OAuth2Mixin.oauth2_request`;
  the only difference is that this method takes a relative path,
  while ``oauth2_request`` takes a complete url.
  
  .. versionchanged:: 3.1
     Added the ability to override ``self._FACEBOOK_BASE_URL``.
docstr_tok: ["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",":","..","testcode",":",":","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","!","''",")","..","testoutput",":",":",":","hide",":","The","given","path","is","relative","to","``","self._FACEBOOK_BASE_URL","``",",","by","default","``","https",":","\/\/graph.facebook.com","''",".","This","method","is","a","wrapper","around","`","OAuth2Mixin.oauth2_request","`",";","the","only","difference","is","that","this","method","takes","a","relative","path",",","while","``","oauth2_request","``","takes","a","complete","url",".","..","versionchanged",":",":","3.1","Added","the","ability","to","override","``","self._FACEBOOK_BASE_URL","``","."]
code: def 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:
  
      ..testcode::
  
          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!")
  
      .. testoutput::
         :hide:
  
      The given path is relative to ``self._FACEBOOK_BASE_URL``,
      by default "https://graph.facebook.com".
  
      This method is a wrapper around `OAuth2Mixin.oauth2_request`;
      the only difference is that this method takes a relative path,
      while ``oauth2_request`` takes a complete url.
  
      .. versionchanged:: 3.1
         Added the ability to override ``self._FACEBOOK_BASE_URL``.
      """
      url = self._FACEBOOK_BASE_URL + path
      # Thanks to the _auth_return_future decorator, our "callback"
      # argument is a Future, which we cannot pass as a callback to
      # oauth2_request. Instead, have oauth2_request return a
      # future and chain them together.
      oauth_future = self.oauth2_request(
          url, access_token=access_token, post_args=post_args, **args
      )
      chain_future(oauth_future, callback)
  
imports: from __future__ import absolute_import, division, print_function
  import base64
  import binascii
  import functools
  import hashlib
  import hmac
  import time
  import uuid
  from tornado.concurrent import TracebackFuture, return_future, chain_future
  from tornado import gen
  from tornado import httpclient
  from tornado import escape
  from tornado.httputil import url_concat
  from tornado.log import gen_log
  from tornado.stack_context import ExceptionStackContext
  from tornado.util import unicode_type, ArgReplacer, PY3
label_desc: Use image node_id 4 for calling the FacebookGraphMixin obj's underlying member method code with example usage: obj.facebook_request(path, callback, access_token, post_args) without return types