o
    Df;                     @   s0   d dl mZ d dlmZmZ G dd deZdS )   )TokenValidator)InvalidTokenErrorInsufficientScopeErrorc                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )	IntrospectTokenValidatorbearerc                 C   s   t  )a  Request introspection token endpoint with the given token string,
        authorization server will return token information in JSON format.
        Developers MUST implement this method before using it::

            def introspect_token(self, token_string):
                # for example, introspection token endpoint has limited
                # internal IPs to access, so there is no need to add
                # authentication.
                url = 'https://example.com/oauth/introspect'
                resp = requests.post(url, data={'token': token_string})
                resp.raise_for_status()
                return resp.json()
        )NotImplementedErrorselftoken_string r   _/home/ubuntu/webapp/venv/lib/python3.10/site-packages/authlib/oauth2/rfc7662/token_validator.pyintrospect_token   s   z)IntrospectTokenValidator.introspect_tokenc                 C   s
   |  |S )N)r   r   r   r   r   authenticate_token   s   
z+IntrospectTokenValidator.authenticate_tokenc                 C   s8   |r|d st | j| jd| |d|rt d S )Nactive)realmextra_attributesscope)r   r   r   scope_insufficientgetr   )r	   tokenscopesrequestr   r   r   validate_token   s
   z'IntrospectTokenValidator.validate_tokenN)__name__
__module____qualname__
TOKEN_TYPEr   r   r   r   r   r   r   r      s
    r   N)rfc6749r   rfc6750r   r   r   r   r   r   r   <module>   s    