o
    =jý
  ã                   @   sD   d Z ddlZddlZddlmZ ddlmZ d
dd„Zd
dd	„ZdS )zEHelper functions for loading data from a Google service account file.é    N)Úcrypt)Ú
exceptionsTc                 C   s`   t |dur|ng ƒ}| |  ¡ ¡}|rt d d |¡¡¡‚|r(tj 	| ¡}|S tj
 	| ¡}|S )aØ  Validates a dictionary containing Google service account data.

    Creates and returns a :class:`google.auth.crypt.Signer` instance from the
    private key specified in the data.

    Args:
        data (Mapping[str, str]): The service account data
        require (Sequence[str]): List of keys required to be present in the
            info.
        use_rsa_signer (Optional[bool]): Whether to use RSA signer or EC signer.
            We use RSA signer by default.

    Returns:
        google.auth.crypt.Signer: A signer created from the private key in the
            service account file.

    Raises:
        MalformedError: if the data was in the wrong format, or if one of the
            required keys is missing.
    NzGService account info was not in the expected format, missing fields {}.z, )ÚsetÚ
differenceÚkeysr   ZMalformedErrorÚformatÚjoinr   Z	RSASignerZfrom_service_account_infoZEsSigner)ÚdataÚrequireÚuse_rsa_signerZkeys_neededÚmissingZsigner© r   úkC:\Users\psant\Downloads\Anu Raj Backend\school\venv\Lib\site-packages\google/auth/_service_account_info.pyÚ	from_dict   s   þþr   c                 C   sP   t j| ddd��}t |¡}|t|||d�fW  d  ƒ S 1 s!w   Y  dS )aó  Reads a Google service account JSON file and returns its parsed info.

    Args:
        filename (str): The path to the service account .json file.
        require (Sequence[str]): List of keys required to be present in the
            info.
        use_rsa_signer (Optional[bool]): Whether to use RSA signer or EC signer.
            We use RSA signer by default.

    Returns:
        Tuple[ Mapping[str, str], google.auth.crypt.Signer ]: The verified
            info and a signer instance.
    Úrzutf-8)Úencoding)r
   r   N)ÚioÚopenÚjsonÚloadr   )Úfilenamer
   r   Z	json_filer	   r   r   r   Úfrom_filename@   s   
$þr   )NT)Ú__doc__r   r   Zgoogle.authr   r   r   r   r   r   r   r   Ú<module>   s   
(