# 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
                    self.get_authenticated_user(self.async_callback(self._on_auth))
                    return
                self.authorize_redirect()

            def _on_auth(self, user):
                if not user:
                    raise tornado.web.HTTPError(500, "Twitter auth failed")
                # Save the user using, e.g., set_secure_cookie()

    The user object returned by get_authenticated_user() includes the
    attributes 'username', 'name', and all of the custom Twitter user
    attributes describe at
    http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-users%C2%A0show
    in addition to 'access_token'. You should save the access token with
    the user; it is required to make requests on behalf of the user later
    with twitter_request().
    """
    _OAUTH_REQUEST_TOKEN_URL = "http://api.twitter.com/oauth/request_token"
    _OAUTH_ACCESS_TOKEN_URL = "http://api.twitter.com/oauth/access_token"
    _OAUTH_AUTHORIZE_URL = "http://api.twitter.com/oauth/authorize"
    _OAUTH_AUTHENTICATE_URL = "http://api.twitter.com/oauth/authenticate"
    _OAUTH_NO_CALLBACKS = False


    def authenticate_redirect(self):
        """Just like authorize_redirect(), but auto-redirects if authorized.

        This is generally the right interface to use if you are using
        Twitter for single-sign on.
        """

# 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

                    self.get_authenticated_user(self.async_callback(self._on_auth))
                    return
                self.authorize_redirect()

            def _on_auth(self, user):
                if not user:
                    raise tornado.web.HTTPError(500, "Twitter auth failed")
                # Save the user using, e.g., set_secure_cookie()

    The user object returned by get_authenticated_user() includes the
    attributes 'username', 'name', and all of the custom Twitter user
    attributes describe at
    http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-users%C2%A0show
    in addition to 'access_token'. You should save the access token with
    the user; it is required to make requests on behalf of the user later
    with twitter_request().
    """
    _OAUTH_REQUEST_TOKEN_URL = "http://api.twitter.com/oauth/request_token"
    _OAUTH_ACCESS_TOKEN_URL = "http://api.twitter.com/oauth/access_token"
    _OAUTH_AUTHORIZE_URL = "http://api.twitter.com/oauth/authorize"
    _OAUTH_AUTHENTICATE_URL = "http://api.twitter.com/oauth/authenticate"
    _OAUTH_NO_CALLBACKS = False


    def authenticate_redirect(self):
        """Just like authorize_redirect(), but auto-redirects if authorized.

        This is generally the right interface to use if you are using
        Twitter for single-sign on.
        """

        http = httpclient.AsyncHTTPClient()