3 L(YX@sdZddlZddlmZddlmZddlmZyddlmZWnek rXdZYnXGdddej Z d d Z Gd d d ej ej ej Z dS) aGoogle 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) app_identityc@s0eZdZdZeddZejej ddZ dS)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. cCsdS)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)selfrrE/private/tmp/pip-build-nl73fm5q/google-auth/google/auth/app_engine.pykey_id,sz Signer.key_idcCstj|}tj|\}}|S)N)rto_bytesrZ sign_blob)rmessage_ signaturerrr sign6s z Signer.signN) __name__ __module__ __qualname____doc__propertyr rcopy_docstringrrrrrrr r%s rcCstdkrtdtjS)zGets the project ID for the current App Engine application. Returns: str: The project ID Raises: EnvironmentError: If the App Engine APIs are unavailable. Nz&The App Engine APIs are not available.)rEnvironmentErrorZget_application_idrrrr get_project_id=s rcseZdZdZdfdd ZejejddZ e ddZ e d d Z ejej d d Zejejd dZe ejejddZe ejejddZZS) CredentialszApp Engine standard environment credentials. These credentials use the App Engine App Identity API to obtain access tokens. Ncs6tdkrtdtt|j||_||_t|_dS)a Args: scopes (Sequence[str]): Scopes to request from the App Identity API. 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. Raises: EnvironmentError: If the App Engine APIs are unavailable. Nz&The App Engine APIs are not available.) rrsuperr__init___scopes_service_account_idr_signer)rscopesservice_account_id) __class__rr rWszCredentials.__init__cCs2tj|j|j\}}tjj|}|||_|_dS)N)rZget_access_tokenrrdatetimeutcfromtimestamptokenexpiry)rrequestr#Zttlr$rrr refreshps zCredentials.refreshcCs|jdkrtj|_|jS)zThe service account email.N)rrZget_service_account_name)rrrr service_account_emailys  z!Credentials.service_account_emailcCs|j S)zChecks if the credentials requires scopes. Returns: bool: True if there are no scopes set otherwise False. )r)rrrr requires_scopesszCredentials.requires_scopescCst||jdS)N)rr)rr)rrrrr with_scopesszCredentials.with_scopescCs |jj|S)N)rr)rr rrr sign_bytesszCredentials.sign_bytescCs|jS)N)r')rrrr signer_emailszCredentials.signer_emailcCs|jS)N)r)rrrr signerszCredentials.signer)NN)rrrrrrrrrr&rr'r(Scopedr)Signingr*r+r, __classcell__rr)r r rOs  r)rr!Z google.authrrrZgoogle.appengine.apir ImportErrorrrr-r.rrrrr s