
    k7i                     ~    S SK Jr  SSKJr  SSKJr  SSKJr  SSKJr   " S S\5      r	 " S	 S
5      r
 " S S5      rg)    )default_json_headers   )InvalidRequestError)Hookable)hooked)OAuth2Requestc                   t   ^  \ rS rSrS/rSr\rS\4U 4S jjr	\
S 5       r     SS jrS rS	 rS
 rSrU =r$ )	BaseGrant	   client_secret_basicNrequestc                 V   > [         TU ]  5         S U l        S U l        Xl        X l        g N)super__init__promptredirect_urir   server)selfr   r   	__class__s      \/home/james-whalen/.local/lib/python3.13/site-packages/authlib/oauth2/rfc6749/grants/base.pyr   BaseGrant.__init__   s'         c                 .    U R                   R                  $ r   )r   clientr   s    r   r   BaseGrant.client   s    ||"""r   c           	          Uc  U R                   nU R                  R                  U R                  R                  UUUUUS9$ )N)r   
grant_typeuserscope
expires_ininclude_refresh_token)
GRANT_TYPEr   generate_tokenr   r   )r   r    r!   r   r"   r#   s         r   r%   BaseGrant.generate_token!   sK     J{{))<<&&!!"7 * 
 	
r   c                     U R                   R                  U R                  U R                  5      nU R                   R	                  SXS9  U$ )a  Authenticate client with the given methods for token endpoint.

For example, the client makes the following HTTP request using TLS:

.. code-block:: http

    POST /token HTTP/1.1
    Host: server.example.com
    Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW
    Content-Type: application/x-www-form-urlencoded

    grant_type=authorization_code&code=SplxlOBeZQQYbYS6WxSbIA
    &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb

Default available methods are: "none", "client_secret_basic" and
"client_secret_post".

:return: client
after_authenticate_client)r   grant)r   authenticate_clientr   TOKEN_ENDPOINT_AUTH_METHODSsend_signal)r   r   s     r   "authenticate_token_endpoint_client,BaseGrant.authenticate_token_endpoint_client4   sF    ( 00LL$::
 	 ;FWr   c                 L    U R                   R                  XR                  5      $ )z%A method to save token into database.)r   
save_tokenr   )r   tokens     r   r0   BaseGrant.save_tokenN   s    {{%%e\\::r   c                 x    U R                   R                  R                  nU R                  R	                  U5      $ )zAValidate if requested scope is supported by Authorization Server.)r   payloadr!   r   validate_requested_scope)r   r!   s     r   r5   "BaseGrant.validate_requested_scopeR   s,    $$**{{33E::r   )r   r   r   r   )NNNNT)__name__
__module____qualname____firstlineno__r+   r$   r   TOKEN_RESPONSE_HEADERr   r   propertyr   r%   r-   r0   r5   __static_attributes____classcell__)r   s   @r   r
   r
   	   se    #8"9 J 1  # #
 "
&4;; ;r   r
   c                   B    \ rS rSrS/rSr\S\4S j5       rS r	S r
Srg)	TokenEndpointMixinX   POSTNr   c                     UR                   R                  U R                  :H  =(       a    UR                  U R                  ;   $ r   )r4   r   r$   methodTOKEN_ENDPOINT_HTTP_METHODSclsr   s     r   check_token_endpoint'TokenEndpointMixin.check_token_endpoint_   s7     OO&&#..8 B#"A"AA	
r   c                     [        5       er   NotImplementedErrorr   s    r   validate_token_request)TokenEndpointMixin.validate_token_requestf       !##r   c                     [        5       er   rK   r   s    r   create_token_response(TokenEndpointMixin.create_token_responsei   rO   r    )r7   r8   r9   r:   rE   r$   classmethodr   rH   rM   rQ   r=   rS   r   r   r@   r@   X   s4    #)( J
= 
 
$$r   r@   c                       \ rS rSr\" 5       rSr\S\4S j5       r	\
S\4S j5       r\
S\4S j5       r\S 5       rS rS	\4S
 jrSrg)AuthorizationEndpointMixinm   Fr   c                 H    UR                   R                  U R                  ;   $ r   )r4   response_typeRESPONSE_TYPESrF   s     r   check_authorization_endpoint7AuthorizationEndpointMixin.check_authorization_endpointq   s    ,,0B0BBBr   c                 l   U R                   R                  (       ac  UR                  U R                   R                  5      (       d#  [        SU R                   R                   S35      eU R                   R                  $ UR	                  5       nU(       d  [        SU R                   R
                  S9eU$ )NzRedirect URI z is not supported by client.z"Missing 'redirect_uri' in request.state)r4   r   check_redirect_urir   get_default_redirect_urir_   )r   r   r   s      r   #validate_authorization_redirect_uri>AuthorizationEndpointMixin.validate_authorization_redirect_uriu   s    ??'',,W__-I-IJJ)#GOO$@$@#AA]^  ??///!::<L)8@U@U   r   c                     U R                   R                  n/ SQnU HD  n[        UR                  U/ 5      5      S:  d  M$  [	        SU S3U R                   R
                  S9e   g)zFor the Authorization Endpoint, request and response parameters MUST NOT be included
more than once. Per `Section 3.1`_.

.. _`Section 3.1`: https://tools.ietf.org/html/rfc6749#section-3.1
)rY   	client_idr   r!   r_      z
Multiple 'z' in request.r^   N)r4   datalistlengetr   r_   )r   rg   
parametersparams       r   &validate_no_multiple_request_parameterAAuthorizationEndpointMixin.validate_no_multiple_request_parameter   s_     ??++U
E8<<r*+a/) }5W__=R=R   r   c                 2    U R                  5       nXl        U$ r   )validate_authorization_requestr   )r   r   s     r   validate_consent_request3AuthorizationEndpointMixin.validate_consent_request   s    ::<(r   c                     [        5       er   rK   r   s    r   ro   9AuthorizationEndpointMixin.validate_authorization_request   rO   r   r   c                     [        5       er   rK   )r   r   
grant_users      r   create_authorization_response8AuthorizationEndpointMixin.create_authorization_response   rO   r   )r   N)r7   r8   r9   r:   setrZ   ERROR_RESPONSE_FRAGMENTrT   r   r[   staticmethodrb   rl   r   rp   ro   strrv   r=   rS   r   r   rV   rV   m   s    UN#C= C C  ]         
$$# $r   rV   N)authlib.constsr   errorsr   hooksr   r   requestsr   r
   r@   rV   rS   r   r   <module>r      s7    / (   $L; L;^$ $*1$ 1$r   