Ë
    W¼Sf»  ã                   óþ   — d Z ddlZddlZddlZddlZddlmZ ddlm	Z	 ddlm
Z
  ej                  «       Zg d¢Z ej                  ddd	g«      Z	  G d
„ d«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Zd„ Zy)zFirebase credentials module.é    N)Úrequests)Úcredentials)Úservice_account)z.https://www.googleapis.com/auth/cloud-platformz)https://www.googleapis.com/auth/datastorez5https://www.googleapis.com/auth/devstorage.read_writez(https://www.googleapis.com/auth/firebasez/https://www.googleapis.com/auth/identitytoolkitz.https://www.googleapis.com/auth/userinfo.emailÚAccessTokenInfoÚaccess_tokenÚexpiryc                   ó   — e Zd ZdZd„ Zd„ Zy)ÚBasez>Provides OAuth2 access tokens for accessing Firebase services.c                 óŒ   — | j                  «       }|j                  t        «       t        |j                  |j
                  «      S )z©Fetches a Google OAuth2 access token using this credential instance.

        Returns:
          AccessTokenInfo: An access token obtained using the credential.
        )Úget_credentialÚrefreshÚ_requestr   Útokenr   )ÚselfÚgoogle_creds     úYC:\Users\user\Documents\project_loop\venv\Lib\site-packages\firebase_admin/credentials.pyÚget_access_tokenzBase.get_access_token/   s9   € ð ×)Ñ)Ó+ˆØ×ÑœHÔ%Ü˜{×0Ñ0°+×2DÑ2DÓEÐEó    c                 ó   — t         ‚)z?Returns the Google credential instance used for authentication.)ÚNotImplementedError©r   s    r   r   zBase.get_credential9   s   € ä!Ð!r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   © r   r   r
   r
   ,   s   „ ÙHòFó"r   r
   c                   ó\   ‡ — e Zd ZdZdZˆ fd„Zed„ «       Zed„ «       Zed„ «       Z	d„ Z
ˆ xZS )ÚCertificatez9A credential initialized from a JSON certificate keyfile.r   c                 ó6  •— t         t        | �  «        t        |«      r*t	        |«      5 }t        j                  |«      }ddd«       n-t        |t        «      r|}nt        dj                  |«      «      ‚j                  d«      | j                  k7  r$t        dj                  | j                  «      «      ‚	 t        j                  j                  |t         ¬«      | _        y# 1 sw Y   ŒwxY w# t        $ r}t        dj                  |«      «      ‚d}~ww xY w)a]  Initializes a credential from a Google service account certificate.

        Service account certificates can be downloaded as JSON files from the Firebase console.
        To instantiate a credential from a certificate file, either specify the file path or a
        dict representing the parsed contents of the file.

        Args:
          cert: Path to a certificate file or a dict representing the contents of a certificate.

        Raises:
          IOError: If the specified certificate file doesn't exist or cannot be read.
          ValueError: If the specified certificate is invalid.
        Nz}Invalid certificate argument: "{0}". Certificate argument must be a file path, or a dict containing the parsed file contents.ÚtypezZInvalid service account certificate. Certificate must contain a "type" field set to "{0}".©Úscopesz?Failed to initialize a certificate credential. Caused by: "{0}")Úsuperr   Ú__init__Ú_is_file_pathÚopenÚjsonÚloadÚ
isinstanceÚdictÚ
ValueErrorÚformatÚgetÚ_CREDENTIAL_TYPEr   ÚCredentialsÚfrom_service_account_infoÚ_scopesÚ_g_credential)r   ÚcertÚ	json_fileÚ	json_dataÚerrorÚ	__class__s        €r   r$   zCertificate.__init__C   s
  ø€ ô 	Œk˜4Ñ)Ô+Ü˜ÔÜ�d“ð 1˜yÜ ŸI™I iÓ0�	÷1ð 1ä˜œdÔ#Ø‰IäðAßAGÁÈÃóOð Oð �=‰=˜Ó  D×$9Ñ$9Ò9Üð :ß:@¹&À×AVÑAVÓ:WóYð Yð	?Ü!0×!<Ñ!<×!VÑ!VØ¤'ð "Wó "+ˆDÕ÷1ð 1ûô ò 	?Üð 0ß06±°u³ó?ð ?ûð	?ús#   ªC$Â9*C0 Ã$C-Ã0	DÃ9DÄDc                 ó.   — | j                   j                  S ©N)r2   Ú
project_idr   s    r   r:   zCertificate.project_idf   s   € à×!Ñ!×,Ñ,Ð,r   c                 ó.   — | j                   j                  S r9   )r2   Úsignerr   s    r   r<   zCertificate.signerj   s   € à×!Ñ!×(Ñ(Ð(r   c                 ó.   — | j                   j                  S r9   )r2   Úservice_account_emailr   s    r   r>   z!Certificate.service_account_emailn   s   € à×!Ñ!×7Ñ7Ð7r   c                 ó   — | j                   S ©z�Returns the underlying Google credential.

        Returns:
          google.auth.credentials.Credentials: A Google Auth credential instance.©r2   r   s    r   r   zCertificate.get_credentialr   ó   € ð
 ×!Ñ!Ð!r   )r   r   r   r   r.   r$   Úpropertyr:   r<   r>   r   Ú__classcell__©r7   s   @r   r   r   >   sS   ø„ ÙCà(Ðô!?ðF ñ-ó ð-ð ñ)ó ð)ð ñ8ó ð8ö"r   r   c                   ó>   ‡ — e Zd ZdZˆ fd„Zd„ Zed„ «       Zd„ Zˆ xZ	S )ÚApplicationDefaultz(A Google Application Default credential.c                 ó8   •— t         t        | �  «        d| _        y)zæCreates an instance that will use Application Default credentials.

        The credentials will be lazily initialized when get_credential() or
        project_id() is called. See those methods for possible errors raised.
        N)r#   rG   r$   r2   )r   r7   s    €r   r$   zApplicationDefault.__init__}   s   ø€ ô 	Ô  $Ñ0Ô2Ø!ˆÕr   c                 ó:   — | j                  «        | j                  S )a:  Returns the underlying Google credential.

        Raises:
          google.auth.exceptions.DefaultCredentialsError: If Application Default
              credentials cannot be initialized in the current environment.
        Returns:
          google.auth.credentials.Credentials: A Google Auth credential instance.)Ú_load_credentialr2   r   s    r   r   z!ApplicationDefault.get_credential†   s   € ð 	×ÑÔØ×!Ñ!Ð!r   c                 ó:   — | j                  «        | j                  S )a  Returns the project_id from the underlying Google credential.

        Raises:
          google.auth.exceptions.DefaultCredentialsError: If Application Default
              credentials cannot be initialized in the current environment.
        Returns:
          str: The project id.)rJ   Ú_project_idr   s    r   r:   zApplicationDefault.project_id‘   s   € ð 	×ÑÔØ×ÑÐr   c                 ó€   — | j                   s2t        j                  j                  t        ¬«      \  | _         | _        y y )Nr!   )r2   ÚgoogleÚauthÚdefaultr1   rL   r   s    r   rJ   z#ApplicationDefault._load_credential�   s2   € Ø×!Ò!Ü39·;±;×3FÑ3FÌgÐ3FÓ3VÑ0ˆDÔ Õ 0ð "r   )
r   r   r   r   r$   r   rC   r:   rJ   rD   rE   s   @r   rG   rG   z   s*   ø„ Ù2ô"ò	"ð ñ	 ó ð	 öWr   rG   c                   ó\   ‡ — e Zd ZdZdZˆ fd„Zed„ «       Zed„ «       Zed„ «       Z	d„ Z
ˆ xZS )ÚRefreshTokenz8A credential initialized from an existing refresh token.Úauthorized_userc                 óÜ  •— t         t        | �  «        t        |«      r*t	        |«      5 }t        j                  |«      }ddd«       n-t        |t        «      r|}nt        dj                  |«      «      ‚j                  d«      | j                  k7  r$t        dj                  | j                  «      «      ‚t        j                  j                  |t         «      | _        y# 1 sw Y   ŒuxY w)a³  Initializes a credential from a refresh token JSON file.

        The JSON must consist of client_id, client_secret and refresh_token fields. Refresh
        token files are typically created and managed by the gcloud SDK. To instantiate
        a credential from a refresh token file, either specify the file path or a dict
        representing the parsed contents of the file.

        Args:
          refresh_token: Path to a refresh token file or a dict representing the contents of a
              refresh token file.

        Raises:
          IOError: If the specified file doesn't exist or cannot be read.
          ValueError: If the refresh token configuration is invalid.
        Nz�Invalid refresh token argument: "{0}". Refresh token argument must be a file path, or a dict containing the parsed file contents.r    zSInvalid refresh token configuration. JSON must contain a "type" field set to "{0}".)r#   rR   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r   r/   Úfrom_authorized_user_infor1   r2   )r   Úrefresh_tokenr4   r5   r7   s       €r   r$   zRefreshToken.__init__¦   sÓ   ø€ ô  	Œl˜DÑ*Ô,Ü˜Ô'Ü�mÓ$ð 1¨	Ü ŸI™I iÓ0�	÷1ð 1ä˜¤tÔ,Ø%‰IäðGßGMÁvÈmÓG\ó^ð ^ð �=‰=˜Ó  D×$9Ñ$9Ò9Üð :ß:@¹&À×AVÑAVÓ:WóYð Yä(×4Ñ4×NÑNÈyÔZaÓbˆÕ÷1ð 1ús   ªC"Ã"C+c                 ó.   — | j                   j                  S r9   )r2   Ú	client_idr   s    r   rX   zRefreshToken.client_idÆ   s   € à×!Ñ!×+Ñ+Ð+r   c                 ó.   — | j                   j                  S r9   )r2   Úclient_secretr   s    r   rZ   zRefreshToken.client_secretÊ   ó   € à×!Ñ!×/Ñ/Ð/r   c                 ó.   — | j                   j                  S r9   )r2   rV   r   s    r   rV   zRefreshToken.refresh_tokenÎ   r[   r   c                 ó   — | j                   S r@   rA   r   s    r   r   zRefreshToken.get_credentialÒ   rB   r   )r   r   r   r   r.   r$   rC   rX   rZ   rV   r   rD   rE   s   @r   rR   rR   ¡   sT   ø„ ÙBà(Ðôcð@ ñ,ó ð,ð ñ0ó ð0ð ñ0ó ð0ö"r   rR   c                 óN   — 	 t        j                  | «       y# t        $ r Y yw xY w)NTF)ÚpathlibÚPathÚ	TypeError)Úpaths    r   r%   r%   Ú   s(   € ðÜ�‰�TÔØøÜò Ùðús   ‚ ˜	$£$)r   Úcollectionsr'   r_   Úgoogle.authrN   Úgoogle.auth.transportr   Úgoogle.oauth2r   r   ÚRequestr   r1   Ú
namedtupler   r
   r   rG   rR   r%   r   r   r   ú<module>ri      s‘   ðñ #Û Û Û ã Ý *Ý %Ý )ð ˆ8×ÑÓ€ò€ð )�+×(Ñ(Ð):¸^ÈXÐ<VÓW€ð÷"ñ "ô$9"�$ô 9"ôx%W˜ô %WôN6"�4ô 6"órr   