# Path: tornado/httpclient.py
# class HTTPClient(object):
# class AsyncHTTPClient(object):
# class HTTPRequest(object):
# class HTTPResponse(object):
# class HTTPError(Exception):
#     def __init__(self):
#     def __del__(self):
#     def close(self):
#     def fetch(self, request, **kwargs):
#         def callback(response):
#     def _async_clients(cls):
#     def __new__(cls, io_loop=None, max_clients=10, force_instance=False, 
#                 **kwargs):
#     def close(self):
#     def fetch(self, request, callback, **kwargs):
#     def configure(impl, **kwargs):
#     def __init__(self, url, method="GET", headers=None, body=None,
#                  auth_username=None, auth_password=None,
#                  connect_timeout=20.0, request_timeout=20.0,
#                  if_modified_since=None, follow_redirects=True,
#                  max_redirects=5, user_agent=None, use_gzip=True,
#                  network_interface=None, streaming_callback=None,
#                  header_callback=None, prepare_curl_callback=None,
#                  proxy_host=None, proxy_port=None, proxy_username=None,
#                  proxy_password='', allow_nonstandard_methods=False,
#                  validate_cert=True, ca_certs=None,
#                  allow_ipv6=None,
#                  client_key=None, client_cert=None):
#     def __init__(self, request, code, headers={}, buffer=None,
#                  effective_url=None, error=None, request_time=None,
#                  time_info={}):
#     def _get_body(self):
#     def rethrow(self):
#     def __repr__(self):
#     def __init__(self, code, message=None, response=None):
# def main():
# 
# Path: tornado/escape.py
#             def _json_decode(s):
# def xhtml_escape(value):
# def xhtml_unescape(value):
# def json_encode(value):
# def json_decode(value):
# def squeeze(value):
# def url_escape(value):
#     def url_unescape(value, encoding='utf-8'):
#     def url_unescape(value, encoding='utf-8'):
#     def parse_qs_bytes(qs, keep_blank_values=False, strict_parsing=False):
# def utf8(value):
# def to_unicode(value):
# def to_basestring(value):
# def recursive_unicode(obj):
# def linkify(text, shorten=False, extra_params="",
#             require_protocol=False, permitted_protocols=["http", "https"]):
#     def make_link(m):
# def _convert_entity(m):
# def _build_unicode_map():
# _XHTML_ESCAPE_RE = re.compile('[&<>"]')
# _XHTML_ESCAPE_DICT = {'&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;'}
# _UTF8_TYPES = (bytes, type(None))
# _TO_UNICODE_TYPES = (unicode, type(None))
# _BASESTRING_TYPES = (basestring, type(None))
# _URL_RE = re.compile(ur"""\b((?:([\w-]+):(/{1,3})|www[.])(?:(?:(?:[^\s&()]|&amp;|&quot;)*(?:[^!"#$%&'()*+,.:;<=>?@\[\]^`{|}~\s]))|(?:\((?:[^\s&()]|&amp;|&quot;)*\)))+)""")
# _HTML_UNICODE_MAP = _build_unicode_map()
# 
# Path: tornado/httputil.py
# def url_concat(url, args):
#     """Concatenate url and argument dictionary regardless of whether
#     url has existing query parameters.
# 
#     >>> url_concat("http://example.com/foo?a=b", dict(c="d"))
#     'http://example.com/foo?a=b&c=d'
#     """
#     if not args: return url
#     if url[-1] not in ('?', '&'):
#         url += '&' if ('?' in url) else '?'
#     return url + urllib.urlencode(args)
# 
# Path: tornado/util.py
# class ObjectDict(dict):
#     def __getattr__(self, name):
#     def __setattr__(self, name, value):
# def import_object(name):
#     def b(s):
#     def b(s):
# def doctests():


import base64
import binascii
import hashlib
import hmac
import logging
import time
import urllib
import urlparse
import uuid
from tornado import httpclient
from tornado import escape
from tornado.httputil import url_concat
from tornado.util import bytes_type, b
            raise Exception("This service does not support oauth_callback")
        if http_client is None:
            http_client = httpclient.AsyncHTTPClient()
        if getattr(self, "_OAUTH_VERSION", "1.0a") == "1.0a":
            http_client.fetch(
                self._oauth_request_token_url(callback_uri=callback_uri,
                                              extra_params=extra_params),
                self.async_callback(
                    self._on_request_token,
                    self._OAUTH_AUTHORIZE_URL,
                callback_uri))
        else:
            http_client.fetch(
                self._oauth_request_token_url(),
                self.async_callback(
                    self._on_request_token, self._OAUTH_AUTHORIZE_URL,
                    callback_uri))


    def get_authenticated_user(self, callback, http_client=None):
        """Gets the OAuth authorized user and access token on callback.

        This method should be called from the handler for your registered
        OAuth Callback URL to complete the registration process. We call
        callback with the authenticated user, which in addition to standard
        attributes like 'name' includes the 'access_key' attribute, which
        contains the OAuth access you can use to make authorized requests
        to this service on behalf of the user.

        """

# Path: tornado/httpclient.py
# class HTTPClient(object):
# class AsyncHTTPClient(object):
# class HTTPRequest(object):
# class HTTPResponse(object):
# class HTTPError(Exception):
#     def __init__(self):
#     def __del__(self):
#     def close(self):
#     def fetch(self, request, **kwargs):
#         def callback(response):
#     def _async_clients(cls):
#     def __new__(cls, io_loop=None, max_clients=10, force_instance=False, 
#                 **kwargs):
#     def close(self):
#     def fetch(self, request, callback, **kwargs):
#     def configure(impl, **kwargs):
#     def __init__(self, url, method="GET", headers=None, body=None,
#                  auth_username=None, auth_password=None,
#                  connect_timeout=20.0, request_timeout=20.0,
#                  if_modified_since=None, follow_redirects=True,
#                  max_redirects=5, user_agent=None, use_gzip=True,
#                  network_interface=None, streaming_callback=None,
#                  header_callback=None, prepare_curl_callback=None,
#                  proxy_host=None, proxy_port=None, proxy_username=None,
#                  proxy_password='', allow_nonstandard_methods=False,
#                  validate_cert=True, ca_certs=None,
#                  allow_ipv6=None,
#                  client_key=None, client_cert=None):
#     def __init__(self, request, code, headers={}, buffer=None,
#                  effective_url=None, error=None, request_time=None,
#                  time_info={}):
#     def _get_body(self):
#     def rethrow(self):
#     def __repr__(self):
#     def __init__(self, code, message=None, response=None):
# def main():
# 
# Path: tornado/escape.py
#             def _json_decode(s):
# def xhtml_escape(value):
# def xhtml_unescape(value):
# def json_encode(value):
# def json_decode(value):
# def squeeze(value):
# def url_escape(value):
#     def url_unescape(value, encoding='utf-8'):
#     def url_unescape(value, encoding='utf-8'):
#     def parse_qs_bytes(qs, keep_blank_values=False, strict_parsing=False):
# def utf8(value):
# def to_unicode(value):
# def to_basestring(value):
# def recursive_unicode(obj):
# def linkify(text, shorten=False, extra_params="",
#             require_protocol=False, permitted_protocols=["http", "https"]):
#     def make_link(m):
# def _convert_entity(m):
# def _build_unicode_map():
# _XHTML_ESCAPE_RE = re.compile('[&<>"]')
# _XHTML_ESCAPE_DICT = {'&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;'}
# _UTF8_TYPES = (bytes, type(None))
# _TO_UNICODE_TYPES = (unicode, type(None))
# _BASESTRING_TYPES = (basestring, type(None))
# _URL_RE = re.compile(ur"""\b((?:([\w-]+):(/{1,3})|www[.])(?:(?:(?:[^\s&()]|&amp;|&quot;)*(?:[^!"#$%&'()*+,.:;<=>?@\[\]^`{|}~\s]))|(?:\((?:[^\s&()]|&amp;|&quot;)*\)))+)""")
# _HTML_UNICODE_MAP = _build_unicode_map()
# 
# Path: tornado/httputil.py
# def url_concat(url, args):
#     """Concatenate url and argument dictionary regardless of whether
#     url has existing query parameters.
# 
#     >>> url_concat("http://example.com/foo?a=b", dict(c="d"))
#     'http://example.com/foo?a=b&c=d'
#     """
#     if not args: return url
#     if url[-1] not in ('?', '&'):
#         url += '&' if ('?' in url) else '?'
#     return url + urllib.urlencode(args)
# 
# Path: tornado/util.py
# class ObjectDict(dict):
#     def __getattr__(self, name):
#     def __setattr__(self, name, value):
# def import_object(name):
#     def b(s):
#     def b(s):
# def doctests():


# Path: tornado/auth.py
import base64
import binascii
import hashlib
import hmac
import logging
import time
import urllib
import urlparse
import uuid
from tornado import httpclient
from tornado import escape
from tornado.httputil import url_concat
from tornado.util import bytes_type, b

            raise Exception("This service does not support oauth_callback")
        if http_client is None:
            http_client = httpclient.AsyncHTTPClient()
        if getattr(self, "_OAUTH_VERSION", "1.0a") == "1.0a":
            http_client.fetch(
                self._oauth_request_token_url(callback_uri=callback_uri,
                                              extra_params=extra_params),
                self.async_callback(
                    self._on_request_token,
                    self._OAUTH_AUTHORIZE_URL,
                callback_uri))
        else:
            http_client.fetch(
                self._oauth_request_token_url(),
                self.async_callback(
                    self._on_request_token, self._OAUTH_AUTHORIZE_URL,
                    callback_uri))


    def get_authenticated_user(self, callback, http_client=None):
        """Gets the OAuth authorized user and access token on callback.

        This method should be called from the handler for your registered
        OAuth Callback URL to complete the registration process. We call
        callback with the authenticated user, which in addition to standard
        attributes like 'name' includes the 'access_key' attribute, which
        contains the OAuth access you can use to make authorized requests
        to this service on behalf of the user.

        """

        request_key = escape.utf8(self.get_argument("oauth_token"))