# 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
        server is unable to locate the token using the given hint, it MUST
        extend its search accross all of its supported token types.  An
        authorization server MAY ignore this parameter, particularly if it is
        able to detect the token type automatically.  This specification
        defines two such values:

                *  access_token: An Access Token as defined in [RFC6749],
                    `section 1.4`_

                *  refresh_token: A Refresh Token as defined in [RFC6749],
                    `section 1.5`_

                Specific implementations, profiles, and extensions of this
                specification MAY define other values for this parameter using
                the registry defined in `Section 4.1.2`_.

        The client also includes its authentication credentials as described in
        `Section 2.3`_. of [`RFC6749`_].

        .. _`section 1.4`: http://tools.ietf.org/html/rfc6749#section-1.4
        .. _`section 1.5`: http://tools.ietf.org/html/rfc6749#section-1.5
        .. _`section 2.3`: http://tools.ietf.org/html/rfc6749#section-2.3
        .. _`Section 4.1.2`: http://tools.ietf.org/html/draft-ietf-oauth-revocation-11#section-4.1.2
        .. _`RFC6749`: http://tools.ietf.org/html/rfc6749
        """
        if not request.token:
            raise InvalidRequestError(request=request,
                    description='Missing token parameter.')

        if not self.request_validator.authenticate_client(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

        server is unable to locate the token using the given hint, it MUST
        extend its search accross all of its supported token types.  An
        authorization server MAY ignore this parameter, particularly if it is
        able to detect the token type automatically.  This specification
        defines two such values:

                *  access_token: An Access Token as defined in [RFC6749],
                    `section 1.4`_

                *  refresh_token: A Refresh Token as defined in [RFC6749],
                    `section 1.5`_

                Specific implementations, profiles, and extensions of this
                specification MAY define other values for this parameter using
                the registry defined in `Section 4.1.2`_.

        The client also includes its authentication credentials as described in
        `Section 2.3`_. of [`RFC6749`_].

        .. _`section 1.4`: http://tools.ietf.org/html/rfc6749#section-1.4
        .. _`section 1.5`: http://tools.ietf.org/html/rfc6749#section-1.5
        .. _`section 2.3`: http://tools.ietf.org/html/rfc6749#section-2.3
        .. _`Section 4.1.2`: http://tools.ietf.org/html/draft-ietf-oauth-revocation-11#section-4.1.2
        .. _`RFC6749`: http://tools.ietf.org/html/rfc6749
        """
        if not request.token:
            raise InvalidRequestError(request=request,
                    description='Missing token parameter.')

        if not self.request_validator.authenticate_client(request):

            raise InvalidClientError(request=request)