# 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
# -*- coding: utf-8 -*-
"""
oauthlib.oauth2.rfc6749.endpoint.revocation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

An implementation of the OAuth 2 `Token Revocation`_ spec (draft 11).

.. _`Token Revocation`: http://tools.ietf.org/html/draft-ietf-oauth-revocation-11
"""
from __future__ import absolute_import, unicode_literals




class RevocationEndpoint(BaseEndpoint):
    """Token revocation endpoint.

    Endpoint used by authenticated clients to revoke access and refresh tokens.
    Commonly this will be part of the Authorization Endpoint.
    """

    valid_token_types = ('access_token', 'refresh_token')

    @property
    def supported_token_types(self):
        return self._supported_token_types

    def __init__(self, request_validator, supported_token_types=None):

# 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

# -*- coding: utf-8 -*-
"""
oauthlib.oauth2.rfc6749.endpoint.revocation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

An implementation of the OAuth 2 `Token Revocation`_ spec (draft 11).

.. _`Token Revocation`: http://tools.ietf.org/html/draft-ietf-oauth-revocation-11
"""
from __future__ import absolute_import, unicode_literals




class RevocationEndpoint(BaseEndpoint):
    """Token revocation endpoint.

    Endpoint used by authenticated clients to revoke access and refresh tokens.
    Commonly this will be part of the Authorization Endpoint.
    """

    valid_token_types = ('access_token', 'refresh_token')

    @property
    def supported_token_types(self):
        return self._supported_token_types

    def __init__(self, request_validator, supported_token_types=None):

        BaseEndpoint.__init__(self)