o
    Df                     @   s<   d Z ddlmZ ddgZG dd deZG dd deZdS )ah  
    authlib.rfc6750.errors
    ~~~~~~~~~~~~~~~~~~~~~~

    OAuth Extensions Error Registration. When a request fails,
    the resource server responds using the appropriate HTTP
    status code and includes one of the following error codes
    in the response.

    https://tools.ietf.org/html/rfc6750#section-6.2

    :copyright: (c) 2017 by Hsiaoming Yang.
   )OAuth2ErrorInvalidTokenErrorInsufficientScopeErrorc                       s>   e Zd ZdZdZdZdZ		d
 fdd	Z fdd	Z  Z	S )r   a@  The access token provided is expired, revoked, malformed, or
    invalid for other reasons. The resource SHOULD respond with
    the HTTP 401 (Unauthorized) status code.  The client MAY
    request a new access token and retry the protected resource
    request.

    https://tools.ietf.org/html/rfc6750#section-3.1
    invalid_tokenzWThe access token provided is expired, revoked, malformed, or invalid for other reasons.i  Nc                    s"   t  |||| || _|| _d S )N)super__init__realmextra_attributes)selfdescriptionuristatus_codestater   r	   	__class__ V/home/ubuntu/webapp/venv/lib/python3.10/site-packages/authlib/oauth2/rfc6750/errors.pyr   %   s
   
zInvalidTokenError.__init__c                    s   t   }g } jr|d j d  jr$| fdd jD  |d j d   }|d| d |ddd	| f |S )
a  If the protected resource request does not include authentication
        credentials or does not contain an access token that enables access
        to the protected resource, the resource server MUST include the HTTP
        "WWW-Authenticate" response header field; it MAY include it in
        response to other conditions as well.

        https://tools.ietf.org/html/rfc6750#section-3
        zrealm=""c                    s"   g | ]}| d  j |  dqS )z="r   )r	   ).0kr
   r   r   
<listcomp>;   s   " z1InvalidTokenError.get_headers.<locals>.<listcomp>zerror="zerror_description="zWWW-AuthenticatezBearer z, )	r   get_headersr   appendr	   extenderrorget_error_descriptionjoin)r
   headersextraserror_descriptionr   r   r   r   ,   s   
	zInvalidTokenError.get_headers)NNNNN)
__name__
__module____qualname____doc__r   r   r   r   r   __classcell__r   r   r   r   r      s    c                   @   s   e Zd ZdZdZdZdZdS )r   aA  The request requires higher privileges than provided by the
    access token. The resource server SHOULD respond with the HTTP
    403 (Forbidden) status code and MAY include the "scope"
    attribute with the scope necessary to access the protected
    resource.

    https://tools.ietf.org/html/rfc6750#section-3.1
    insufficient_scopezIThe request requires higher privileges than provided by the access token.i  N)r!   r"   r#   r$   r   r   r   r   r   r   r   r   E   s
    N)r$   baser   __all__r   r   r   r   r   r   <module>   s    0