
    Ki,                         d dl mZ d dlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ dd	lmZ dd
lmZ  G d d      Z G d deee      Z G d dee	ee      Zy)    )URL)RedirectResponse   )BaseApp)
OAuthError)AsyncOAuth1Mixin)AsyncOAuth2Mixin)AsyncOpenIDMixin)AsyncOAuth1Client)AsyncOAuth2Clientc                       e Zd Zd ZddZy)StarletteAppMixinc                    K   |j                  dd       }|rK| j                  j                  rd }n|j                  }| j                  j	                  |||       d {    y t        d      7 w)NstatezMissing state value)pop	frameworkcachesessionset_state_dataRuntimeError)selfrequestkwargsr   r   s        v/home/jay/workspace/scripts/.codegraph-venv/lib/python3.12/site-packages/authlib/integrations/starlette_client/apps.pysave_authorize_dataz%StarletteAppMixin.save_authorize_data   sb     

7D)~~##!//..//GGG455 Hs   AA/A-A/Nc                    K   |rt        |t              rt        |      } | j                  |fi | d{   } | j                  |fd|i| d{    t        |d   d      S 7 17 w)a'  Create a HTTP Redirect for Authorization Endpoint.

        :param request: HTTP request instance from Starlette view.
        :param redirect_uri: Callback or redirect URI for authorization.
        :param kwargs: Extra parameters to include.
        :return: A HTTP redirect response.
        Nredirect_uriurli.  )status_code)
isinstancer   strcreate_authorization_urlr   r   )r   r   r   r   rvs        r   authorize_redirectz$StarletteAppMixin.authorize_redirect   ss      J|S9|,L0400HHH&d&&wP\PRPPP5	s;; IPs!   4A,A(A,A*A,*A,)N)__name__
__module____qualname__r   r$        r   r   r      s    	6<r)   r   c                       e Zd ZeZd Zy)StarletteOAuth1Appc                   K   t        |j                        }|j                  d      }|st        d      | j                  j                  |j                  |       d {   }|st        d      |d   |d<   |j                  |       | j                  j                  |j                  |       d {     | j                  di | d {   S 7 s7  7 w)Noauth_tokenzMissing "oauth_token" parameter)descriptionz)Missing "request_token" in temporary datarequest_tokenr(   )
dictquery_paramsgetr   r   get_state_datar   updateclear_state_datafetch_access_token)r   r   r   paramsr   datas         r   authorize_access_tokenz)StarletteOAuth1App.authorize_access_token,   s     g**+

=))JKK^^227??EJJ)TUU"&"7fnn--goouEEE,T,,6v666 K 	F6s7   AC C!AC5C6CCCCCN)r%   r&   r'   r   
client_clsr9   r(   r)   r   r+   r+   )   s    "J7r)   r+   c                       e Zd ZeZd Zy)StarletteOAuth2Appc                 `  K   |j                   j                  dd      dk(  r}|j                  j                  d      }|r(|j                  j                  d      }t        ||      |j                  j                  d      |j                  j                  d      d}nL|j	                         4 d {   }|j                  d      |j                  d      d}d d d       d {    | j
                  j                  rd }n|j                  }| j
                  j                  |j                  d             d {   }| j
                  j                  ||j                  d             d {    | j                  ||      }|j                  d	d       }	|j                  d
d       }
|j                  dd      } | j                  di || d {   }d|v r*d|v r&| j                  ||d   |	|
|       d {   }||d<   |S 7 W7 '# 1 d {  7  sw Y   8xY w7 7 7 T7 -w)NmethodGETerrorerror_description)r@   r.   coder   )rB   r   claims_options
claims_clsleewayx   id_tokennonce)rH   rC   rD   rE   userinfor(   )scoper2   r1   r   formr   r   r   r3   r5   _format_state_paramsr   r6   parse_id_token)r   r   r   r@   r.   r7   rK   r   
state_datarC   rD   rE   tokenrI   s                 r   r9   z)StarletteOAuth2App.authorize_access_tokenA   s    ==Xu-6((,,W5E%22667JK u+FF  ,,008 --11':F
 ||~   HHV,!XXg.  >>GooG>>88&**WBUVV
nn--gvzz'7JKKK**:v>$4d;ZZd3
Hc*-d--AA&AA7j#8!00 )-% 1  H !)E*;     WK Bs   B1H.3H
4H.7$HH.&H'AH.>H&?2H.1H(2A#H.H*(H.>H,?H.H.H#HH#	H.(H.*H.,H.N)r%   r&   r'   r   r:   r9   r(   r)   r   r<   r<   <   s     #J)r)   r<   N)starlette.datastructuresr   starlette.responsesr   base_clientr   r   base_client.async_appr   r	   base_client.async_openidr
   httpx_clientr   r   r   r+   r<   r(   r)   r   <module>rV      sQ    ( 0 ! $ 4 4 7 , ,< <87*,<g 7&.')97.r)   