class_docstr: Abstract implementation of OAuth 2.0.
  
  See `FacebookGraphMixin` or `GoogleOAuth2Mixin` below for example
  implementations.
  
  Class attributes:
  
  * ``_OAUTH_AUTHORIZE_URL``: The service's authorization url.
  * ``_OAUTH_ACCESS_TOKEN_URL``:  The service's access token url.
class_docstr_tok: ["Abstract","implementation","of","OAuth","2.0",".","See","`","FacebookGraphMixin","`","or","`","GoogleOAuth2Mixin","`","below","for","example","implementations",".","Class","attributes",":","*","``","_OAUTH_AUTHORIZE_URL","``",":","The","service","'s","authorization","url",".","*","``","_OAUTH_ACCESS_TOKEN_URL","``",":","The","service","'s","access","token","url","."]
docstr: Fetches the given URL auth an OAuth2 access token.
  
  If the request is a POST, ``post_args`` should be provided. Query
  string arguments should be given as keyword arguments.
  
  Example usage:
  
  ..testcode::
  
      class MainHandler(tornado.web.RequestHandler,
                        tornado.auth.FacebookGraphMixin):
          @tornado.web.authenticated
          @tornado.gen.coroutine
          def get(self):
              new_entry = yield self.oauth2_request(
                  "https://graph.facebook.com/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:
  
  .. versionadded:: 4.3
docstr_tok: ["Fetches","the","given","URL","auth","an","OAuth2","access","token",".","If","the","request","is","a","POST",",","``","post_args","``","should","be","provided",".","Query","string","arguments","should","be","given","as","keyword","arguments",".","Example","usage",":","..","testcode",":",":","class","MainHandler","(","tornado.web.RequestHandler",",","tornado.auth.FacebookGraphMixin",")",":","@","tornado.web.authenticated","@","tornado.gen.coroutine","def","get","(","self",")",":","new_entry","=","yield","self.oauth2_request","(","``","https",":","\/\/graph.facebook.com\/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",":","..","versionadded",":",":","4.3"]
code: def oauth2_request(
      self, url, callback, access_token=None, post_args=None, **args
  ):
      """Fetches the given URL auth an OAuth2 access token.
  
      If the request is a POST, ``post_args`` should be provided. Query
      string arguments should be given as keyword arguments.
  
      Example usage:
  
      ..testcode::
  
          class MainHandler(tornado.web.RequestHandler,
                            tornado.auth.FacebookGraphMixin):
              @tornado.web.authenticated
              @tornado.gen.coroutine
              def get(self):
                  new_entry = yield self.oauth2_request(
                      "https://graph.facebook.com/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:
  
      .. versionadded:: 4.3
      """
      all_args = {}
      if access_token:
          all_args["access_token"] = access_token
          all_args.update(args)
  
      if all_args:
          url += "?" + urllib_parse.urlencode(all_args)
      callback = functools.partial(self._on_oauth2_request, callback)
      http = self.get_auth_http_client()
      if post_args is not None:
          http.fetch(
              url,
              method="POST",
              body=urllib_parse.urlencode(post_args),
              callback=callback,
          )
      else:
          http.fetch(url, callback=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 3 for calling the OAuth2Mixin obj's underlying member method code with example usage: obj.oauth2_request(url, callback, access_token, post_args) without return types