� J�g���T�ddlmZmZmZddlmZddlmZmZm Z Gd�d��Z dS)�)� url_decode�add_params_to_uri�urlparse)� json_loads�)�SIGNATURE_HMAC_SHA1�SIGNATURE_TYPE_HEADER� ClientAuthc ���eZdZeZddddddeeddf d�Zed���Z e j d���Z ed���Z e j d���Z dd�Z d �Z dd �Zd �Zd �Zd �Zed���Zd�ZdS)� OAuth1ClientNFc ��|std���||_|�|||||| | ||| | �� � |_| |_dS)NzMissing "client_id") � client_secret�token� token_secret� redirect_uri�signature_method�signature_type�rsa_key�verifier�realm�force_include_body)� ValueError�session� auth_class�auth�_kwargs)�selfr� client_idrrrrrrrrrr�kwargss �e/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/authlib/oauth1/client.py�__init__zOAuth1Client.__init__sh�� � 4��2�3�3� 3��� ��O�O� �]��l�%�-�)����1�$�  �  �� ��� � � �c��|jjS�N�rr�rs r rzOAuth1Client.redirect_uri(s ���y�%�%r"c��||j_dSr$r%)r�uris r rzOAuth1Client.redirect_uri,s��!$�� ���r"c�b�t|jj|jj|jj���S)N)� oauth_token�oauth_token_secret�oauth_verifier)�dictrrrrr&s r rzOAuth1Client.token0s0���� ��#�y�5��9�-� � � � r"c��|�&d|j_d|j_d|j_dSd|vrB|d|j_d|vr|d|j_d|vr|d|j_dSdSd|��}|�d|��dS)z�This token setter is designed for an easy integration for OAuthClient. Make sure both OAuth1Session and OAuth2Session have token setters. Nr*r+r,zoauth_token is missing: � missing_token)rrrr� handle_error)rr�messages r rzOAuth1Client.token8s��� �=�"�D�I�O�%)�D�I� "�!%�D�I� � � � �e� #� #�#�M�2�D�I�O�#�u�,�,�).�/C�)D�� �&��5�(�(�%*�+;�%<�� �"�"�"�)�(�;��:�:�G� � � �o�w� 7� 7� 7� 7� 7r"c ��|p |jj|d<|jjr|jj|d<t||�����S)a�Create an authorization URL by appending request_token and optional kwargs to url. This is the second step in the OAuth 1 workflow. The user should be redirected to this authorization URL, grant access to you, and then be redirected back to you. The redirection back can either be specified during client registration or by supplying a callback URI per request. :param url: The authorization endpoint URL. :param request_token: The previously obtained request token. :param kwargs: Optional parameters to append to the URL. :returns: The authorization URL with new parameters embedded. r*�oauth_callback)rrrr�items)r�url� request_tokenrs r �create_authorization_urlz%OAuth1Client.create_authorization_urlLsL��!.� @�����}�� �9� !� >�'+�y�'=�F�#� $� ��f�l�l�n�n�5�5�5r"c ��|j|fi|��S)a�Method for fetching an access token from the token endpoint. This is the first step in the OAuth 1 workflow. A request token is obtained by making a signed post request to url. The token is then parsed from the application/x-www-form-urlencoded response and ready to be used to construct an authorization url. :param url: Request Token endpoint. :param kwargs: Extra parameters to include for fetching token. :return: A Request Token dict. )� _fetch_token)rr5rs r �fetch_request_tokenz OAuth1Client.fetch_request_token_s��!�t� ��/�/��/�/�/r"c �~�|r ||j_|jjs|�dd��|j|fi|��S)a�Method for fetching an access token from the token endpoint. This is the final step in the OAuth 1 workflow. An access token is obtained using all previously obtained credentials, including the verifier from the authorization step. :param url: Access Token endpoint. :param verifier: A verifier string to prove authorization was granted. :param kwargs: Extra parameters to include for fetching access token. :return: A token dict. �missing_verifierzMissing "verifier" value)rrr0r9)rr5rrs r �fetch_access_tokenzOAuth1Client.fetch_access_tokenmsW�� � *�!)�D�I� ��y�!� N� � � �0�2L� M� M� M� �t� ��/�/��/�/�/r"c�z�tttj|��j����}||_|S)a)Extract parameters from the post authorization redirect response URL. :param url: The full URL that resulted from the user being redirected back from the OAuth provider to you, the client. :returns: A dict of parameters extracted from the URL. )r-rr�queryr)rr5rs r �parse_authorization_responsez)OAuth1Client.parse_authorization_responses3���Z�� 1�#� 6� 6� <�=�=�>�>���� �� r"c ��|jj|fd|ji|��}|�|j|j��}||_d|j_|S)Nr)r�postr�parse_response_token� status_code�textrr)rr5r�resprs r r9zOAuth1Client._fetch_token�sU�� �t�|� ��?�?�4�9�?��?�?���)�)�$�*:�D�I�F�F���� �!�� ��� r"c��|dkr,d�||��}|�d|�� |���}|�d��rt |��}nt t |����}n=#ttf$r)}d�|��}t|���d}~wwxYw|S)Ni�z5Token request failed with code {}, response was '{}'.�fetch_token_denied�{z�Unable to decode token from token response. This is commonly caused by an unsuccessful request where a non urlencoded error message is returned. The decoding error was {}) �formatr0�strip� startswithrr-r� TypeErrorr)rrDrEr1r�e�errors r rCz!OAuth1Client.parse_response_token�s��� �#� � �%��f�[�$�'�'� � � � �2�G� <� <� <� $��:�:�<�<�D����s�#�#� /�"�4�(�(����Z��-�-�.�.�����:�&� $� $� $�,��f�Q�i�i� � �U�#�#� #����� $����� s�AB � C�$B?�?Cc�*�t|�d|�����)Nz: )r)� error_type�error_descriptions r r0zOAuth1Client.handle_error�s���J�=�=�*;�=�=�>�>�>r"c��|jr|`dSdSr$)rr&s r �__del__zOAuth1Client.__del__�s�� �<� �� � � � � r"r$)�__name__� __module__� __qualname__r rrr r!�propertyr�setterrr7r:r=r@r9rC� staticmethodr0rT�r"r r r sG�������J�9=��$�"�D�4�"5� 5�$)�� ����.�&�&��X�&���%�%���%�� � ��X� � �\�8�8��\�8�&6�6�6�6�& 0� 0� 0�0�0�0�0�$ � � �������0�?�?��\�?�����r"r N) �authlib.common.urlsrrr�authlib.common.encodingr�rfc5849rr r r r[r"r �<module>r_s������������� /�.�.�.�.�.�����������b�b�b�b�b�b�b�b�b�br"
Memory