ó
O'—^c           @  s„  d  Z  d d l m Z d d l Z d d l m Z m Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ	 d	 e f d
 „  ƒ  YZ
 d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d  „  ƒ  YZ d! e f d" „  ƒ  YZ d# e f d$ „  ƒ  YZ d% e f d& „  ƒ  YZ d' e f d( „  ƒ  YZ d) e f d* „  ƒ  YZ d+ e f d, „  ƒ  YZ d- e f d. „  ƒ  YZ d/ e f d0 „  ƒ  YZ d1 e f d2 „  ƒ  YZ d3 e f d4 „  ƒ  YZ d5 e f d6 „  ƒ  YZ  d7 e f d8 „  ƒ  YZ! d d9 „ Z# d S(:   u¿   
oauthlib.oauth2.rfc6749.errors
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Error used both by OAuth 2 clients and providers to represent the spec
defined error responses for all four core grant types.
iÿÿÿÿ(   t   unicode_literalsN(   t	   urlencodet   add_params_to_urit   OAuth2Errorc           B  sh   e  Z d Z d  Z d Z d d d d d d „ Z d „  Z e d „  ƒ Z	 e d „  ƒ Z
 e d „  ƒ Z RS(   i  u    c         C  sÝ   | p |  j  |  _  d |  j |  j  f } | rE | d t | ƒ 7} n  t t |  ƒ j | ƒ | |  _ | |  _ | r | |  _ n  | rÙ | j	 |  _	 | j
 |  _
 | j |  _ | j |  _ | j |  _ | sÙ | j |  _ qÙ n  d S(   u®  
        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
        u   (%s) %su    N(   t   descriptiont   errort   reprt   superR   t   __init__t   urit   statet   status_codet   redirect_urit	   client_idt   scopest   response_typet
   grant_type(   t   selfR   R	   R
   R   t   requestt   message(    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR      s"    		c         C  s   t  | |  j ƒ S(   N(   R   t	   twotuples(   R   R	   (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyt   in_uri=   s    c         C  s|   d |  j  f g } |  j r4 | j d |  j f ƒ n  |  j rV | j d |  j f ƒ n  |  j rx | j d |  j f ƒ n  | S(   Nu   erroru   error_descriptionu	   error_uriu   state(   R   R   t   appendR	   R
   (   R   R   (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR   @   s    			c         C  s   t  |  j ƒ S(   N(   R   R   (   R   (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyt
   urlencodedK   s    c         C  s   t  j t |  j ƒ ƒ S(   N(   t   jsont   dumpst   dictR   (   R   (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR   O   s    N(   t   __name__t
   __module__t   NoneR   R   R   R   R   t   propertyR   R   R   (    (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR      s   )	t   TokenExpiredErrorc           B  s   e  Z d  Z RS(   u   token_expired(   R   R   R   (    (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR   T   s   t   InsecureTransportErrorc           B  s   e  Z d  Z d Z RS(   u   insecure_transportu   OAuth 2 MUST utilize https.(   R   R   R   R   (    (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR    X   s   t   MismatchingStateErrorc           B  s   e  Z d  Z d Z RS(   u   mismatching_stateu6   CSRF Warning! State not equal in request and response.(   R   R   R   R   (    (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR!   ]   s   t   MissingCodeErrorc           B  s   e  Z d  Z RS(   u   missing_code(   R   R   R   (    (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR"   b   s   t   MissingTokenErrorc           B  s   e  Z d  Z RS(   u   missing_token(   R   R   R   (    (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR#   f   s   t   MissingTokenTypeErrorc           B  s   e  Z d  Z RS(   u   missing_token_type(   R   R   R   (    (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR$   j   s   t   FatalClientErrorc           B  s   e  Z d  Z RS(   uÊ  Errors during authorization where user should not be redirected back.

    If the request fails due to a missing, invalid, or mismatching
    redirection URI, or if the client identifier is missing or invalid,
    the authorization server SHOULD inform the resource owner of the
    error and MUST NOT automatically redirect the user-agent to the
    invalid redirection URI.

    Instead the user should be informed of the error by the provider itself.
    (   R   R   t   __doc__(    (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR%   n   s   t   InvalidRequestFatalErrorc           B  s   e  Z d  Z d Z RS(   u°   For fatal errors, the request is missing a required parameter, includes
    an invalid parameter value, includes a parameter more than once, or is
    otherwise malformed.
    u   invalid_request(   R   R   R&   R   (    (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR'   }   s   t   InvalidRedirectURIErrorc           B  s   e  Z d  Z RS(   u   Invalid redirect URI.(   R   R   R   (    (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR(   …   s   t   MissingRedirectURIErrorc           B  s   e  Z d  Z RS(   u   Missing redirect URI.(   R   R   R   (    (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR)   ‰   s   t   MismatchingRedirectURIErrorc           B  s   e  Z d  Z RS(   u   Mismatching redirect URI.(   R   R   R   (    (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR*      s   t   InvalidClientIdErrorc           B  s   e  Z d  Z RS(   u"   Invalid client_id parameter value.(   R   R   R   (    (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR+   ‘   s   t   MissingClientIdErrorc           B  s   e  Z d  Z RS(   u   Missing client_id parameter.(   R   R   R   (    (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR,   •   s   t   InvalidRequestErrorc           B  s   e  Z d  Z d Z RS(   už   The request is missing a required parameter, includes an invalid
    parameter value, includes a parameter more than once, or is
    otherwise malformed.
    u   invalid_request(   R   R   R&   R   (    (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR-   ™   s   t   MissingResponseTypeErrorc           B  s   e  Z d  Z RS(   u    Missing response_type parameter.(   R   R   R   (    (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR.   ¢   s   t   AccessDeniedErrorc           B  s   e  Z d  Z d Z d Z RS(   u>   The resource owner or authorization server denied the request.u   access_deniedi‘  (   R   R   R&   R   R   (    (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR/   ¦   s   t   UnsupportedResponseTypeErrorc           B  s   e  Z d  Z d Z RS(   ue   The authorization server does not support obtaining an authorization
    code using this method.
    u   unsupported_response_type(   R   R   R&   R   (    (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR0   ­   s   t   InvalidScopeErrorc           B  s   e  Z d  Z d Z d Z RS(   u6   The requested scope is invalid, unknown, or malformed.u   invalid_scopei‘  (   R   R   R&   R   R   (    (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR1   µ   s   t   ServerErrorc           B  s   e  Z d  Z d Z RS(   u  The authorization server encountered an unexpected condition that
    prevented it from fulfilling the request.  (This error code is needed
    because a 500 Internal Server Error HTTP status code cannot be returned
    to the client via a HTTP redirect.)
    u   server_error(   R   R   R&   R   (    (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR2   ¼   s   t   TemporarilyUnavailableErrorc           B  s   e  Z d  Z d Z RS(   u  The authorization server is currently unable to handle the request
    due to a temporary overloading or maintenance of the server.
    (This error code is needed because a 503 Service Unavailable HTTP
    status code cannot be returned to the client via a HTTP redirect.)
    u   temporarily_unavailable(   R   R   R&   R   (    (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR3   Æ   s   t   InvalidClientErrorc           B  s   e  Z d  Z d Z d Z RS(   uB  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.
    u   invalid_clienti‘  (   R   R   R&   R   R   (    (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR4   Ð   s   t   InvalidGrantErrorc           B  s   e  Z d  Z d Z d Z RS(   uý   The provided authorization grant (e.g. authorization code, resource
    owner credentials) or refresh token is invalid, expired, revoked, does
    not match the redirection URI used in the authorization request, or was
    issued to another client.
    u   invalid_granti‘  (   R   R   R&   R   R   (    (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR5   à   s   t   UnauthorizedClientErrorc           B  s   e  Z d  Z d Z d Z RS(   uY   The authenticated client is not authorized to use this authorization
    grant type.
    u   unauthorized_clienti‘  (   R   R   R&   R   R   (    (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR6   ë   s   t   UnsupportedGrantTypeErrorc           B  s   e  Z d  Z d Z RS(   uS   The authorization grant type is not supported by the authorization
    server.
    u   unsupported_grant_type(   R   R   R&   R   (    (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR7   ô   s   t   UnsupportedTokenTypeErrorc           B  s   e  Z d  Z d Z RS(   u¼   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.
    u   unsupported_token_type(   R   R   R&   R   (    (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyR8   ü   s   c         C  s   d d  l  } d d  l } i | j d ƒ d 6| j d ƒ d 6| j d ƒ d 6} xH | j | j t | j ƒ D]* \ } } | j |  k rk | |   ‚ qk qk Wd  S(   Niÿÿÿÿu   error_descriptionu   descriptionu	   error_uriu   uriu   state(   t   inspectt   syst   gett
   getmemberst   modulesR   t   isclassR   (   R   t   paramsR9   R:   t   kwargst   _t   cls(    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyt   raise_from_error  s    )($   R&   t
   __future__R    R   t   oauthlib.commonR   R   t	   ExceptionR   R   R    R!   R"   R#   R$   R%   R'   R(   R)   R*   R+   R,   R-   R.   R/   R0   R1   R2   R3   R4   R5   R6   R7   R8   R   RC   (    (    (    s@   /tmp/pip-unpacked-wheel-eAx2J6/oauthlib/oauth2/rfc6749/errors.pyt   <module>   s<   F	

		