
    g                         d Z ddl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	ej                        Z
d
 Z G d dej                  ej                  ej                        Zy# e	$ r dZY Mw xY w)a  Google App Engine standard environment support.

This module provides authentication and signing for applications running on App
Engine in the standard environment using the `App Identity API`_.


.. _App Identity API:
    https://cloud.google.com/appengine/docs/python/appidentity/
    N)_helpers)credentials)crypt)
exceptions)app_identityc                   d    e Zd ZdZed        Z ej                  ej                        d        Z
y)SignerzSigns messages using the App Engine App Identity service.

    This can be used in place of :class:`google.auth.crypt.Signer` when
    running in the App Engine standard environment.
    c                      y)zOptional[str]: The key ID used to identify this private key.

        .. warning::
           This is always ``None``. The key ID used by App Engine can not
           be reliably determined ahead of time.
        N selfs    s/var/www/html/FastMealFinder_FlaskServer-InitialRelease/venv/lib/python3.12/site-packages/google/auth/app_engine.pykey_idzSigner.key_id/   s         c                 `    t        j                  |      }t        j                  |      \  }}|S N)r   to_bytesr   	sign_blob)r   message_	signatures       r   signzSigner.sign9   s,    ##G,#--g69r   N)__name__
__module____qualname____doc__propertyr   r   copy_docstringr   r	   r   r   r   r   r	   r	   (   s@       XU\\* +r   r	   c                  `    t         t        j                  d      t        j                         S )zGets the project ID for the current App Engine application.

    Returns:
        str: The project ID

    Raises:
        google.auth.exceptions.OSError: If the App Engine APIs are unavailable.
    &The App Engine APIs are not available.)r   r   OSErrorget_application_idr   r   r   get_project_idr#   @   s+       !IJJ**,,r   c                       e Zd ZdZ	 	 	 	 d fd	Z ej                  ej                        d        Z	e
d        Ze
d        Z ej                  ej                        dd       Z ej                  ej                        d        Z ej                  ej"                        d        Ze
 ej                  ej"                        d	               Ze
 ej                  ej"                        d
               Z xZS )CredentialszApp Engine standard environment credentials.

    These credentials use the App Engine App Identity API to obtain access
    tokens.
    c                     t         t        j                  d      t        t        |           || _        || _        || _        t               | _
        || _        y)a  
        Args:
            scopes (Sequence[str]): Scopes to request from the App Identity
                API.
            default_scopes (Sequence[str]): Default scopes passed by a
                Google client library. Use 'scopes' for user-defined scopes.
            service_account_id (str): The service account ID passed into
                :func:`google.appengine.api.app_identity.get_access_token`.
                If not specified, the default application service account
                ID will be used.
            quota_project_id (Optional[str]): The project ID used for quota
                and billing.

        Raises:
            google.auth.exceptions.OSError: If the App Engine APIs are unavailable.
        Nr    )r   r   r!   superr%   __init___scopes_default_scopes_service_account_idr	   _signer_quota_project_id)r   scopesdefault_scopesservice_account_idquota_project_id	__class__s        r   r(   zCredentials.__init__Z   sR    4 $$%MNNk4)+-#5 x!1r   c                     | j                   | j                   n| j                  }t        j                  || j                        \  }}t
        j
                  j                  |      }||c| _        | _        y r   )	r)   r*   r   get_access_tokenr+   datetimeutcfromtimestamptokenexpiry)r   requestr.   r7   ttlr8   s         r   refreshzCredentials.refresh~   s^    !%!9t?S?S!2264;S;ST
s""33C8"'
DKr   c                 d    | j                   t        j                         | _         | j                   S )zThe service account email.)r+   r   get_service_account_namer   s    r   service_account_emailz!Credentials.service_account_email   s-     ##+'3'L'L'ND$'''r   c                 :    | j                    xr | j                   S )zChecks if the credentials requires scopes.

        Returns:
            bool: True if there are no scopes set otherwise False.
        )r)   r*   r   s    r   requires_scopeszCredentials.requires_scopes   s     <<<(<(<$<<r   c                 T    | j                  ||| j                  | j                        S )N)r.   r/   r0   r1   )r2   r+   r1   )r   r.   r/   s      r   with_scopeszCredentials.with_scopes   s0    ~~)#77!22	  
 	
r   c                 R    | j                  | j                  | j                  |      S )N)r.   r0   r1   )r2   r)   r+   )r   r1   s     r   with_quota_projectzCredentials.with_quota_project   s+    ~~<<#77-  
 	
r   c                 8    | j                   j                  |      S r   )r,   r   )r   r   s     r   
sign_byteszCredentials.sign_bytes   s    ||  ))r   c                     | j                   S r   )r>   r   s    r   signer_emailzCredentials.signer_email   s     )))r   c                     | j                   S r   )r,   r   s    r   signerzCredentials.signer   s     ||r   )NNNNr   )r   r   r   r   r(   r   r   r   r%   r;   r   r>   r@   ScopedrB   CredentialsWithQuotaProjectrD   SigningrF   rH   rJ   __classcell__)r2   s   @r   r%   r%   Q   s?    "2H X[4450 60 ( ( = = X[//0
 1
 X[DDE
 F
 X[001* 2* X[001* 2 * X[001 2 r   r%   )r   r5   google.authr   r   r   r   google.appengine.apir   ImportErrorr	   r#   rK   rM   rL   r%   r   r   r   <module>rR      st       #  "1U\\ 0-"c++[-T-Tc]  Ls   A* *A43A4