# Path: twitter-winner/oauthlib/oauth2/rfc6749/endpoints/base.py
# class BaseEndpoint(object):
#     def __init__(self):
#         self._available = True
#         self._catch_errors = False
# 
#     @property
#     def available(self):
#         return self._available
# 
#     @available.setter
#     def available(self, available):
#         self._available = available
# 
#     @property
#     def catch_errors(self):
#         return self._catch_errors
# 
#     @catch_errors.setter
#     def catch_errors(self, catch_errors):
#         self._catch_errors = catch_errors
# 
# def catch_errors_and_unavailability(f):
#     @functools.wraps(f)
#     def wrapper(endpoint, uri, *args, **kwargs):
#         if not endpoint.available:
#             e = TemporarilyUnavailableError()
#             log.info('Endpoint unavailable, ignoring request %s.' % uri)
#             return {}, e.json, 503
# 
#         if endpoint.catch_errors:
#             try:
#                 return f(endpoint, uri, *args, **kwargs)
#             except OAuth2Error:
#                 raise
#             except FatalClientError:
#                 raise
#             except Exception as e:
#                 error = ServerError()
#                 log.warning('Exception caught while processing request, %s.' % e)
#                 return {}, error.json, 500
#         else:
#             return f(endpoint, uri, *args, **kwargs)
#     return wrapper
# 
# Path: twitter-winner/oauthlib/oauth2/rfc6749/errors.py
# class InvalidClientError(OAuth2Error):
#     """Client authentication failed (e.g. unknown client, no client
#     authentication included, or unsupported authentication method).
#     The authorization server MAY return an HTTP 401 (Unauthorized) status
#     code to indicate which HTTP authentication schemes are supported.
#     If the client attempted to authenticate via the "Authorization" request
#     header field, the authorization server MUST respond with an
#     HTTP 401 (Unauthorized) status code, and include the "WWW-Authenticate"
#     response header field matching the authentication scheme used by the
#     client.
#     """
#     error = 'invalid_client'
#     status_code = 401
# 
# class UnsupportedTokenTypeError(OAuth2Error):
#     """The authorization server does not support the revocation of the
#     presented token type.  I.e. the client tried to revoke an access token
#     on a server not supporting this feature.
#     """
#     error = 'unsupported_token_type'
# 
# Path: twitter-winner/oauthlib/oauth2/rfc6749/errors.py
# class InvalidRequestError(OAuth2Error):
#     """The request is missing a required parameter, includes an invalid
#     parameter value, includes a parameter more than once, or is
#     otherwise malformed.
#     """
#     error = 'invalid_request'
# 
# class OAuth2Error(Exception):
#     error = None
#     status_code = 400
# 
#     def __init__(self, description=None, uri=None, state=None, status_code=None,
#                  request=None):
#         """
#         description:    A human-readable ASCII [USASCII] text providing
#                         additional information, used to assist the client
#                         developer in understanding the error that occurred.
#                         Values for the "error_description" parameter MUST NOT
#                         include characters outside the set
#                         x20-21 / x23-5B / x5D-7E.
# 
#         uri:    A URI identifying a human-readable web page with information
#                 about the error, used to provide the client developer with
#                 additional information about the error.  Values for the
#                 "error_uri" parameter MUST conform to the URI- Reference
#                 syntax, and thus MUST NOT include characters outside the set
#                 x21 / x23-5B / x5D-7E.
# 
#         state:  A CSRF protection value received from the client.
# 
#         request:  Oauthlib Request object
#         """
#         self.description = description
#         self.uri = uri
#         self.state = state
# 
#         if status_code:
#             self.status_code = status_code
# 
#         if request:
#             self.redirect_uri = request.redirect_uri
#             self.client_id = request.client_id
#             self.scopes = request.scopes
#             self.response_type = request.response_type
#             self.grant_type = request.grant_type
# 
#     def in_uri(self, uri):
#         return add_params_to_uri(uri, self.twotuples)
# 
#     @property
#     def twotuples(self):
#         error = [('error', self.error)]
#         if self.description:
#             error.append(('error_description', self.description))
#         if self.uri:
#             error.append(('error_uri', self.uri))
#         if self.state:
#             error.append(('state', self.state))
#         return error
# 
#     @property
#     def urlencoded(self):
#         return urlencode(self.twotuples)
# 
#     @property
#     def json(self):
#         return json.dumps(dict(self.twotuples))


from oauthlib.common import Request, log
from .base import BaseEndpoint, catch_errors_and_unavailability
from ..errors import InvalidClientError, UnsupportedTokenTypeError
from ..errors import InvalidRequestError, OAuth2Error
        BaseEndpoint.__init__(self)
        self.request_validator = request_validator
        self._supported_token_types = (
                supported_token_types or self.valid_token_types)

    @catch_errors_and_unavailability
    def create_revocation_response(self, uri, http_method='POST', body=None,
            headers=None):
        """Revoke supplied access or refresh token.


        The authorization server responds with HTTP status code 200 if the
        token has been revoked sucessfully or if the client submitted an
        invalid token.

        Note: invalid tokens do not cause an error response since the client
        cannot handle such an error in a reasonable way.  Moreover, the purpose
        of the revocation request, invalidating the particular token, is
        already achieved.

        The content of the response body is ignored by the client as all
        necessary information is conveyed in the response code.

        An invalid token type hint value is ignored by the authorization server
        and does not influence the revocation response.
        """
        request = Request(uri, http_method=http_method, body=body, headers=headers)
        try:
            self.validate_revocation_request(request)
            log.debug('Token revocation valid for %r.', request)

# Path: twitter-winner/oauthlib/oauth2/rfc6749/endpoints/base.py
# class BaseEndpoint(object):
#     def __init__(self):
#         self._available = True
#         self._catch_errors = False
# 
#     @property
#     def available(self):
#         return self._available
# 
#     @available.setter
#     def available(self, available):
#         self._available = available
# 
#     @property
#     def catch_errors(self):
#         return self._catch_errors
# 
#     @catch_errors.setter
#     def catch_errors(self, catch_errors):
#         self._catch_errors = catch_errors
# 
# def catch_errors_and_unavailability(f):
#     @functools.wraps(f)
#     def wrapper(endpoint, uri, *args, **kwargs):
#         if not endpoint.available:
#             e = TemporarilyUnavailableError()
#             log.info('Endpoint unavailable, ignoring request %s.' % uri)
#             return {}, e.json, 503
# 
#         if endpoint.catch_errors:
#             try:
#                 return f(endpoint, uri, *args, **kwargs)
#             except OAuth2Error:
#                 raise
#             except FatalClientError:
#                 raise
#             except Exception as e:
#                 error = ServerError()
#                 log.warning('Exception caught while processing request, %s.' % e)
#                 return {}, error.json, 500
#         else:
#             return f(endpoint, uri, *args, **kwargs)
#     return wrapper
# 
# Path: twitter-winner/oauthlib/oauth2/rfc6749/errors.py
# class InvalidClientError(OAuth2Error):
#     """Client authentication failed (e.g. unknown client, no client
#     authentication included, or unsupported authentication method).
#     The authorization server MAY return an HTTP 401 (Unauthorized) status
#     code to indicate which HTTP authentication schemes are supported.
#     If the client attempted to authenticate via the "Authorization" request
#     header field, the authorization server MUST respond with an
#     HTTP 401 (Unauthorized) status code, and include the "WWW-Authenticate"
#     response header field matching the authentication scheme used by the
#     client.
#     """
#     error = 'invalid_client'
#     status_code = 401
# 
# class UnsupportedTokenTypeError(OAuth2Error):
#     """The authorization server does not support the revocation of the
#     presented token type.  I.e. the client tried to revoke an access token
#     on a server not supporting this feature.
#     """
#     error = 'unsupported_token_type'
# 
# Path: twitter-winner/oauthlib/oauth2/rfc6749/errors.py
# class InvalidRequestError(OAuth2Error):
#     """The request is missing a required parameter, includes an invalid
#     parameter value, includes a parameter more than once, or is
#     otherwise malformed.
#     """
#     error = 'invalid_request'
# 
# class OAuth2Error(Exception):
#     error = None
#     status_code = 400
# 
#     def __init__(self, description=None, uri=None, state=None, status_code=None,
#                  request=None):
#         """
#         description:    A human-readable ASCII [USASCII] text providing
#                         additional information, used to assist the client
#                         developer in understanding the error that occurred.
#                         Values for the "error_description" parameter MUST NOT
#                         include characters outside the set
#                         x20-21 / x23-5B / x5D-7E.
# 
#         uri:    A URI identifying a human-readable web page with information
#                 about the error, used to provide the client developer with
#                 additional information about the error.  Values for the
#                 "error_uri" parameter MUST conform to the URI- Reference
#                 syntax, and thus MUST NOT include characters outside the set
#                 x21 / x23-5B / x5D-7E.
# 
#         state:  A CSRF protection value received from the client.
# 
#         request:  Oauthlib Request object
#         """
#         self.description = description
#         self.uri = uri
#         self.state = state
# 
#         if status_code:
#             self.status_code = status_code
# 
#         if request:
#             self.redirect_uri = request.redirect_uri
#             self.client_id = request.client_id
#             self.scopes = request.scopes
#             self.response_type = request.response_type
#             self.grant_type = request.grant_type
# 
#     def in_uri(self, uri):
#         return add_params_to_uri(uri, self.twotuples)
# 
#     @property
#     def twotuples(self):
#         error = [('error', self.error)]
#         if self.description:
#             error.append(('error_description', self.description))
#         if self.uri:
#             error.append(('error_uri', self.uri))
#         if self.state:
#             error.append(('state', self.state))
#         return error
# 
#     @property
#     def urlencoded(self):
#         return urlencode(self.twotuples)
# 
#     @property
#     def json(self):
#         return json.dumps(dict(self.twotuples))


# Path: twitter-winner/oauthlib/oauth2/rfc6749/endpoints/revocation.py
from oauthlib.common import Request, log
from .base import BaseEndpoint, catch_errors_and_unavailability
from ..errors import InvalidClientError, UnsupportedTokenTypeError
from ..errors import InvalidRequestError, OAuth2Error

        BaseEndpoint.__init__(self)
        self.request_validator = request_validator
        self._supported_token_types = (
                supported_token_types or self.valid_token_types)

    @catch_errors_and_unavailability
    def create_revocation_response(self, uri, http_method='POST', body=None,
            headers=None):
        """Revoke supplied access or refresh token.


        The authorization server responds with HTTP status code 200 if the
        token has been revoked sucessfully or if the client submitted an
        invalid token.

        Note: invalid tokens do not cause an error response since the client
        cannot handle such an error in a reasonable way.  Moreover, the purpose
        of the revocation request, invalidating the particular token, is
        already achieved.

        The content of the response body is ignored by the client as all
        necessary information is conveyed in the response code.

        An invalid token type hint value is ignored by the authorization server
        and does not influence the revocation response.
        """
        request = Request(uri, http_method=http_method, body=body, headers=headers)
        try:
            self.validate_revocation_request(request)
            log.debug('Token revocation valid for %r.', request)

        except OAuth2Error as e: