Ë
    ùmxi¬k  ã                   ót  — d Z ddlZddlZddlmZ ddlm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 dd	lmZ dd
lmZ ddlmZ dZdZdZdZdZdZdZej2                  dfd„Z G d„ dej6                  ej8                  ej:                  ej<                  «      Z G d„ dej8                  «      Z g fd„Z!y)aÇ  Google Cloud Impersonated credentials.

This module provides authentication for applications where local credentials
impersonates a remote service account using `IAM Credentials API`_.

This class can be used to impersonate a service account as long as the original
Credential object has the "Service Account Token Creator" role on the target
service account.

    .. _IAM Credentials API:
        https://cloud.google.com/iam/credentials/reference/rest/
é    N)Údatetime)Ú_exponential_backoff)Ú_helpers©Úcredentials)Ú
exceptions)Úiam)Újwt)Úmetrics)Ú_clientz*Unable to acquire impersonated credentialsi  z#https://oauth2.googleapis.com/tokenzKhttps://iamcredentials.{}/v1/projects/-/serviceAccounts/{}/allowedLocationsÚauthorized_userÚservice_accountÚ external_account_authorized_userc                 óÂ  — |xs= t         j                  j                  t        j                  |«      j                  |«      }t        j                  |«      j                  d«      } | |d||¬«      }t        |j                  d«      r|j                  j                  d«      n|j                  }|j                  t        j                  k7  rt        j                   t"        |«      ‚	 t        j$                  |«      }	|	d   }
t'        j(                  |	d   d«      }|
|fS # t*        t,        f$ r1}t        j                   dj                  t"        «      |«      }||‚d	}~ww xY w)
aÅ  Makes a request to the Google Cloud IAM service for an access token.
    Args:
        request (Request): The Request object to use.
        principal (str): The principal to request an access token for.
        headers (Mapping[str, str]): Map of headers to transmit.
        body (Mapping[str, str]): JSON Payload body for the iamcredentials
            API call.
        iam_endpoint_override (Optiona[str]): The full IAM endpoint override
            with the target_principal embedded. This is useful when supporting
            impersonation with regional endpoints.

    Raises:
        google.auth.exceptions.TransportError: Raised if there is an underlying
            HTTP connection error
        google.auth.exceptions.RefreshError: Raised if the impersonated
            credentials are not available.  Common reasons are
            `iamcredentials.googleapis.com` is not enabled or the
            `Service Account Token Creator` is not assigned
    úutf-8ÚPOST©ÚurlÚmethodÚheadersÚbodyÚdecodeÚaccessTokenÚ
expireTimez%Y-%m-%dT%H:%M:%SZz6{}: No access token or invalid expiration in response.N)r	   Ú_IAM_ENDPOINTÚreplacer   ÚDEFAULT_UNIVERSE_DOMAINÚformatÚjsonÚdumpsÚencodeÚhasattrÚdatar   ÚstatusÚhttp_clientÚOKr   ÚRefreshErrorÚ_REFRESH_ERRORÚloadsr   ÚstrptimeÚKeyErrorÚ
ValueError)ÚrequestÚ	principalr   r   Úuniverse_domainÚiam_endpoint_overrideÚiam_endpointÚresponseÚresponse_bodyÚtoken_responseÚtokenÚexpiryÚ
caught_excÚnew_excs                 ú[/home/htdocs/ttos/venv/lib/python3.12/site-packages/google/auth/impersonated_credentials.pyÚ_make_iam_token_requestr:   <   s=  € ð6 )ò ¬C×,=Ñ,=×,EÑ,EÜ×+Ñ+¨_ó-ç�fˆYÓð ô �:‰:�dÓ×"Ñ" 7Ó+€Dá˜<°ÀÈdÔS€Hô
 �8—=‘= (Ô+ð 	�‰×Ñ˜WÔ%à�]‰]ð ð ‡�œ+Ÿ.™.Ò(Ü×%Ñ%¤n°mÓDÐDð&ÜŸ™ MÓ2ˆØ˜}Ñ-ˆÜ×"Ñ" >°,Ñ#?ÐAUÓVˆà�fˆ}Ðøä”jÐ!ò &Ü×)Ñ)ØD×KÑKÜóð ó	
ˆð ˜:Ð%ûð&ús   Ã'6D ÄEÄ-,EÅEc                   ó²  ‡ — e Zd ZdZddedddfˆ fd„	Zd„ Zd„ Zd„ Zd„ Z	e
d„ «       Ze
d	„ «       Ze
d
„ «       Ze
d„ «       Z ej                   ej$                  «      d„ «       Zd„ Z ej                   ej*                  «      d„ «       Z ej                   ej.                  «      d„ «       Z ej                   ej2                  «      dd„«       Zedd„«       Zˆ xZS )ÚCredentialsar
  This module defines impersonated credentials which are essentially
    impersonated identities.

    Impersonated Credentials allows credentials issued to a user or
    service account to impersonate another. The target service account must
    grant the originating credential principal the
    `Service Account Token Creator`_ IAM role:

    For more information about Token Creator IAM role and
    IAMCredentials API, see
    `Creating Short-Lived Service Account Credentials`_.

    .. _Service Account Token Creator:
        https://cloud.google.com/iam/docs/service-accounts#the_service_account_token_creator_role

    .. _Creating Short-Lived Service Account Credentials:
        https://cloud.google.com/iam/docs/creating-short-lived-service-account-credentials

    Usage:

    First grant source_credentials the `Service Account Token Creator`
    role on the target account to impersonate.   In this example, the
    service account represented by svc_account.json has the
    token creator role on
    `impersonated-account@_project_.iam.gserviceaccount.com`.

    Enable the IAMCredentials API on the source project:
    `gcloud services enable iamcredentials.googleapis.com`.

    Initialize a source credential which does not have access to
    list bucket::

        from google.oauth2 import service_account

        target_scopes = [
            'https://www.googleapis.com/auth/devstorage.read_only']

        source_credentials = (
            service_account.Credentials.from_service_account_file(
                '/path/to/svc_account.json',
                scopes=target_scopes))

    Now use the source credentials to acquire credentials to impersonate
    another service account::

        from google.auth import impersonated_credentials

        target_credentials = impersonated_credentials.Credentials(
          source_credentials=source_credentials,
          target_principal='impersonated-account@_project_.iam.gserviceaccount.com',
          target_scopes = target_scopes,
          lifetime=500)

    Resource access is granted::

        client = storage.Client(credentials=target_credentials)
        buckets = client.list_buckets(project='your_project')
        for bucket in buckets:
          print(bucket.name)

    **IMPORTANT**:
    This class does not validate the credential configuration. A security
    risk occurs when a credential configuration configured with malicious urls
    is used.
    When the credential configuration is accepted from an
    untrusted source, you should validate it before using.
    Refer https://cloud.google.com/docs/authentication/external/externally-sourced-credentials for more details.
    Nc
                 ó€  •— t         t        | �  «        t        j                  |«      | _        t        | j                  t        j                  «      ru| j                  j                  t        j                  «      | _        t        | j                  d«      r1| j                  j                  r| j                  j                  d«       |j                  | _        || _        || _        || _        || _        |xs t(        | _        d| _        t/        j0                  «       | _        || _        || _        d| _        |	| _        y)ap  
        Args:
            source_credentials (google.auth.Credentials): The source credential
                used as to acquire the impersonated credentials.
            target_principal (str): The service account to impersonate.
            target_scopes (Sequence[str]): Scopes to request during the
                authorization grant.
            delegates (Sequence[str]): The chained list of delegates required
                to grant the final access_token.  If set, the sequence of
                identities must have "Service Account Token Creator" capability
                granted to the prceeding identity.  For example, if set to
                [serviceAccountB, serviceAccountC], the source_credential
                must have the Token Creator role on serviceAccountB.
                serviceAccountB must have the Token Creator on
                serviceAccountC.
                Finally, C must have Token Creator on target_principal.
                If left unset, source_credential must have that role on
                target_principal.
            lifetime (int): Number of seconds the delegated credential should
                be valid for (upto 3600).
            quota_project_id (Optional[str]): The project ID used for quota and billing.
                This project may be different from the project used to
                create the credentials.
            iam_endpoint_override (Optional[str]): The full IAM endpoint override
                with the target_principal embedded. This is useful when supporting
                impersonation with regional endpoints.
            subject (Optional[str]): sub field of a JWT. This field should only be set
                if you wish to impersonate as a user. This feature is useful when
                using domain wide delegation.
            trust_boundary (Mapping[str,str]): A credential trust boundary.
        Ú_create_self_signed_jwtN)Úsuperr<   Ú__init__ÚcopyÚ_source_credentialsÚ
isinstancer   ÚScopedÚwith_scopesr	   Ú
_IAM_SCOPEr"   Ú_always_use_jwt_accessr>   r/   Ú_universe_domainÚ_target_principalÚ_target_scopesÚ
_delegatesÚ_subjectÚ_DEFAULT_TOKEN_LIFETIME_SECSÚ	_lifetimer5   r   Úutcnowr6   Ú_quota_project_idÚ_iam_endpoint_overrideÚ_cred_file_pathÚ_trust_boundary)ÚselfÚsource_credentialsÚtarget_principalÚtarget_scopesÚ	delegatesÚsubjectÚlifetimeÚquota_project_idr0   Útrust_boundaryÚ	__class__s             €r9   r@   zCredentials.__init__Å   s  ø€ ôX 	Œk˜4Ñ)Ô+ä#'§9¡9Ð-?Ó#@ˆÔ ô �d×.Ñ.´×0BÑ0BÔCØ'+×'?Ñ'?×'KÑ'KÜ—‘ó(ˆDÔ$ô ˜×0Ñ0Ð2KÔLØ×,Ñ,×CÒCà×(Ñ(×@Ñ@ÀÔFà 2× BÑ BˆÔØ!1ˆÔØ+ˆÔØ#ˆŒØˆŒØ!ÒAÔ%AˆŒØˆŒ
Ü—o‘oÓ'ˆŒØ!1ˆÔØ&;ˆÔ#Ø#ˆÔØ-ˆÕó    c                 ó"   — t         j                  S ©N)r   ÚCRED_TYPE_SA_IMPERSONATE©rT   s    r9   Ú_metric_header_for_usagez$Credentials._metric_header_for_usage  s   € Ü×/Ñ/Ð/r^   c                 óx  — | j                   j                  t        j                  j                  k(  s1| j                   j                  t        j                  j
                  k(  r| j                   j                  |«       | j                  | j                  t        | j                  «      dz   dœ}ddt        j                  t        j                  «       i}| j                   j                  |«       | j                  �r| j                   t        j"                  k7  rt%        j&                  d«      ‚t)        j*                  «       }| j,                  t)        j.                  | j                  xs d«      | j                  t0        t)        j2                  |«      t)        j2                  |«      t4        z   dœ}t7        || j,                  ||| j                  ¬«      }t9        j:                  |t0        |«      \  | _        | _        }y	tA        || j,                  ||| j                   | jB                  ¬
«      \  | _        | _        y	)zòUpdates credentials with a new access_token representing
        the impersonated account.

        Args:
            request (google.auth.transport.requests.Request): Request object
                to use for refreshing credentials.
        Ús)rX   ÚscoperZ   úContent-Typeúapplication/jsonzNDomain-wide delegation is not supported in universes other than googleapis.com© )Úissrf   ÚsubÚaudÚiatÚexp)r-   r.   r   ÚpayloadrX   N)r-   r.   r   r   r/   r0   )"rB   Útoken_stater   Ú
TokenStateÚSTALEÚINVALIDÚrefreshrK   rJ   ÚstrrN   r   ÚAPI_CLIENT_HEADERÚ&token_request_access_token_impersonateÚapplyrL   r/   r   r   ÚGoogleAuthErrorr   rO   rI   Úscopes_to_stringÚ_GOOGLE_OAUTH2_TOKEN_ENDPOINTÚdatetime_to_secsrM   Ú_sign_jwt_requestr   Ú	jwt_grantr5   r6   r:   rQ   )rT   r-   r   r   Únowro   Ú	assertionÚ_s           r9   Ú_perform_refresh_tokenz"Credentials._perform_refresh_token  sÙ  € ð ×$Ñ$×0Ñ0´K×4JÑ4J×4PÑ4PÒPØ×'Ñ'×3Ñ3´{×7MÑ7M×7UÑ7UÒUà×$Ñ$×,Ñ,¨WÔ5ð Ÿ™Ø×(Ñ(Ü˜DŸN™NÓ+¨cÑ1ñ
ˆð Ð.Ü×%Ñ%¤w×'UÑ'UÓ'Wð
ˆð 	× Ñ ×&Ñ& wÔ/ð �=‹=Ø×#Ñ#¤{×'JÑ'JÒJÜ ×0Ñ0ð,óð ô
 —/‘/Ó#ˆCà×-Ñ-Ü!×2Ñ2°4×3FÑ3FÒ3LÈ"ÓMØ—}‘}Ü4Ü×0Ñ0°Ó5Ü×0Ñ0°Ó5Ô8TÑTñˆGô *ØØ×0Ñ0ØØØŸ/™/ôˆIô *1×):Ñ):ØÔ6¸	ó*Ñ&ˆDŒJ˜œ Qð ä"9ØØ×,Ñ,ØØØ ×0Ñ0Ø"&×"=Ñ"=ô#
ÑˆŒ
�D•Kr^   c                 ó„   — | j                   st        d«      ‚t        j                  | j                  | j                   «      S )aî  Builds and returns the URL for the trust boundary lookup API.

        This method constructs the specific URL for the IAM Credentials API's
        `allowedLocations` endpoint, using the credential's universe domain
        and service account email.

        Raises:
            ValueError: If `self.service_account_email` is None or an empty
                string, as it's required to form the URL.

        Returns:
            str: The URL for the trust boundary lookup endpoint.
        zIService account email is required to build the trust boundary lookup URL.)Úservice_account_emailr,   Ú_TRUST_BOUNDARY_LOOKUP_ENDPOINTr   r/   rb   s    r9   Ú _build_trust_boundary_lookup_urlz,Credentials._build_trust_boundary_lookup_url[  sC   € ð ×)Ò)ÜØ[óð ô /×5Ñ5Ø× Ñ  $×"<Ñ"<ó
ð 	
r^   c                 óZ  — ddl m} t        j                  j	                  t
        j                  | j                  «      j                  | j                  «      }t        j                  |«      j                  d«      | j                  dœ}ddi} || j                  «      }	 t        j                   «       }|D ]¹  }|j#                  |||¬«      }	|	j$                  t        j&                  v rŒ4|	j$                  t(        j*                  k7  r2t-        j.                  dj                  |	j1                  «       «      «      ‚t        j2                  |	j1                  «       d	   «      c |j5                  «        S  	 |j5                  «        t-        j.                  d
«      ‚# |j5                  «        w xY w)Nr   ©ÚAuthorizedSessionr   )ro   rX   rg   rh   )r   r   r   zError calling sign_bytes: {}Ú
signedBlobz#exhausted signBlob endpoint retries)Úgoogle.auth.transport.requestsr‰   r	   Ú_IAM_SIGN_ENDPOINTr   r   r   r/   r   rI   Úbase64Ú	b64encoder   rK   rB   r   ÚExponentialBackoffÚpostÚstatus_codeÚIAM_RETRY_CODESr%   r&   r   ÚTransportErrorr   Ú	b64decodeÚclose)
rT   Úmessager‰   Úiam_sign_endpointr   r   Úauthed_sessionÚretriesr�   r2   s
             r9   Ú
sign_byteszCredentials.sign_bytesq  sq  € ÝDä×2Ñ2×:Ñ:Ü×/Ñ/°×1EÑ1Eó
ç
‰&�×'Ñ'Ó
(ð 	ô
 ×'Ñ'¨Ó0×7Ñ7¸Ó@ØŸ™ñ
ˆð
 "Ð#5Ð6ˆá*¨4×+CÑ+CÓDˆð	#Ü*×=Ñ=Ó?ˆGØò G�Ø)×.Ñ.Ø)°7Àð /ó �ð ×'Ñ'¬3×+>Ñ+>Ñ>ØØ×'Ñ'¬;¯>©>Ò9Ü$×3Ñ3Ø6×=Ñ=¸h¿m¹m»oÓNóð ô ×'Ñ'¨¯©«¸Ñ(EÓFÑFà× Ñ Õ"ñGð × Ñ Ô"Ü×'Ñ'Ð(MÓNÐNøð × Ñ Õ"ús   Â C F Å1F ÆF*c                 ó   — | j                   S r`   ©rI   rb   s    r9   Úsigner_emailzCredentials.signer_email“  ó   € à×%Ñ%Ð%r^   c                 ó   — | j                   S r`   rœ   rb   s    r9   r„   z!Credentials.service_account_email—  rž   r^   c                 ó   — | S r`   ri   rb   s    r9   ÚsignerzCredentials.signer›  s   € àˆr^   c                 ó   — | j                    S r`   )rJ   rb   s    r9   Úrequires_scopeszCredentials.requires_scopesŸ  s   € à×&Ñ&Ð&Ð&r^   c                 óP   — | j                   r| j                   d| j                  dœS y )Nzimpersonated credentials)Úcredential_sourceÚcredential_typer.   )rR   rI   rb   s    r9   Úget_cred_infozCredentials.get_cred_info£  s/   € à×Òà%)×%9Ñ%9Ø#=Ø!×3Ñ3ñð ð
 r^   c           
      óú   — | j                  | j                  | j                  | j                  | j                  | j
                  | j                  | j                  | j                  ¬«      }| j                  |_	        |S )N)rV   rW   rX   rZ   r[   r0   r\   )
r]   rB   rI   rJ   rK   rN   rP   rQ   rS   rR   )rT   Úcreds     r9   Ú
_make_copyzCredentials._make_copy­  sn   € Ø�~‰~Ø×$Ñ$Ø!×3Ñ3Ø×-Ñ-Ø—o‘oØ—^‘^Ø!×3Ñ3Ø"&×"=Ñ"=Ø×/Ñ/ð ó 	
ˆð  $×3Ñ3ˆÔØˆr^   c                 ó4   — | j                  «       }||_        |S r`   )rª   rS   )rT   r\   r©   s      r9   Úwith_trust_boundaryzCredentials.with_trust_boundary»  s   € à�‰Ó ˆØ-ˆÔØˆr^   c                 ó4   — | j                  «       }||_        |S r`   )rª   rP   )rT   r[   r©   s      r9   Úwith_quota_projectzCredentials.with_quota_projectÁ  s   € à�‰Ó ˆØ!1ˆÔØˆr^   c                 ó<   — | j                  «       }|xs ||_        |S r`   )rª   rJ   )rT   ÚscopesÚdefault_scopesr©   s       r9   rE   zCredentials.with_scopesÇ  s    € à�‰Ó ˆØ$Ò6¨ˆÔØˆr^   c                 ó  — |j                  d«      }|j                  d«      }|t        k(  r"ddlm} |j                  j                  |«      }nz|t        k(  r"ddlm} |j                  j                  |«      }nO|t        k(  r"ddl
m} |j                  j                  |«      }n$t        j                  dj                  |«      «      ‚|j                  d«      }	|	j!                  d	«      }
|	j#                  d
«      }|
dk(  s
|dk(  s|
|kD  r$t        j$                  dj                  |	«      «      ‚|	|
dz   | }|j                  d«      }|j                  d«      }|xs |j                  d«      }|j                  d«      } | ||||||¬«      S )a¶  Creates a Credentials instance from parsed impersonated service account credentials info.

        **IMPORTANT**:
        This method does not validate the credential configuration. A security
        risk occurs when a credential configuration configured with malicious urls
        is used.
        When the credential configuration is accepted from an
        untrusted source, you should validate it before using with this method.
        Refer https://cloud.google.com/docs/authentication/external/externally-sourced-credentials for more details.

        Args:
            info (Mapping[str, str]): The impersonated service account credentials info in Google
                format.
            scopes (Sequence[str]): Optional list of scopes to include in the
                credentials.

        Returns:
            google.oauth2.credentials.Credentials: The constructed
                credentials.

        Raises:
            InvalidType: If the info["source_credentials"] are not a supported impersonation type
            InvalidValue: If the info["service_account_impersonation_url"] is not in the expected format.
            ValueError: If the info is not in the expected format.
        rU   Útyper   r   )r   )r   z.source credential of type {} is not supported.Ú!service_account_impersonation_urlú/z:generateAccessTokenéÿÿÿÿz'Cannot extract target principal from {}é   rX   r[   r°   r\   )r[   r\   )ÚgetÚ'_SOURCE_CREDENTIAL_AUTHORIZED_USER_TYPEÚgoogle.oauth2r   r<   Úfrom_authorized_user_infoÚ'_SOURCE_CREDENTIAL_SERVICE_ACCOUNT_TYPEr   Úfrom_service_account_infoÚ8_SOURCE_CREDENTIAL_EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPEÚgoogle.authr   Ú	from_infor   ÚInvalidTyper   ÚrfindÚfindÚInvalidValue)ÚclsÚinfor°   Úsource_credentials_infoÚsource_credentials_typer   rU   r   r   Úimpersonation_urlÚstart_indexÚ	end_indexrV   rX   r[   r\   s                   r9   Ú&from_impersonated_service_account_infoz2Credentials.from_impersonated_service_account_infoÍ  s£  € ð8 #'§(¡(Ð+?Ó"@ÐØ"9×"=Ñ"=¸fÓ"EÐØ"Ô&MÒMÝ1à!,×!8Ñ!8×!RÑ!RØ'ó"Ñð %Ô(OÒOÝ5à!0×!<Ñ!<×!VÑ!VØ'ó"Ñð $ÜGòHõ Eà!A×!MÑ!M×!WÑ!WØ'ó"Ñô ×(Ñ(Ø@×GÑGØ+óóð ð !ŸH™HÐ%HÓIÐØ'×-Ñ-¨cÓ2ˆØ%×*Ñ*Ð+AÓBˆ	Ø˜"Ò 	¨R¢°;ÀÒ3JÜ×)Ñ)Ø9×@Ñ@ÐARÓSóð ð -¨[¸1©_¸yÐIÐØ—H‘H˜[Ó)ˆ	ØŸ8™8Ð$6Ó7ÐØÒ-˜4Ÿ8™8 HÓ-ˆØŸ™Ð"2Ó3ˆáØØØØØ-Ø)ô
ð 	
r^   r`   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__rM   r@   rc   r‚   r†   rš   Úpropertyr�   r„   r¡   r£   r   Úcopy_docstringr   r<   r§   rª   ÚCredentialsWithTrustBoundaryr¬   ÚCredentialsWithQuotaProjectr®   rD   rE   ÚclassmethodrÌ   Ú__classcell__©r]   s   @r9   r<   r<   z   sF  ø„ ñCðT ØØ-ØØ"ØõI.òV0òF
òP
ò, OðD ñ&ó ð&ð ñ&ó ð&ð ñó ðð ñ'ó ð'ð €X×Ñ˜[×4Ñ4Ó5ñó 6ðòð €X×Ñ˜[×EÑEÓFñó Gðð
 €X×Ñ˜[×DÑDÓEñó Fðð
 €X×Ñ˜[×/Ñ/Ó0òó 1ðð
 òM
ó ôM
r^   r<   c                   óÆ   ‡ — e Zd ZdZ	 	 	 dˆ fd„	Zd	d„Zd„ Zd„ Z ej                  e
j                  «      d„ «       Z ej                  e
j                  «      d„ «       Zˆ xZS )
ÚIDTokenCredentialsz;Open ID Connect ID Token-based service account credentials.c                 ó¬   •— t         t        | �  «        t        |t        «      st        j                  d«      ‚|| _        || _        || _	        || _
        y)a‰  
        Args:
            target_credentials (google.auth.Credentials): The target
                credential used as to acquire the id tokens for.
            target_audience (string): Audience to issue the token for.
            include_email (bool): Include email in IdToken
            quota_project_id (Optional[str]):  The project ID used for
                quota and billing.
        z4Provided Credential must be impersonated_credentialsN)r?   rÙ   r@   rC   r<   r   ry   Ú_target_credentialsÚ_target_audienceÚ_include_emailrP   )rT   Útarget_credentialsÚtarget_audienceÚinclude_emailr[   r]   s        €r9   r@   zIDTokenCredentials.__init__!  sV   ø€ ô  	Ô  $Ñ0Ô2äÐ,¬kÔ:Ü×,Ñ,ØIóð ð $6ˆÔ Ø /ˆÔØ+ˆÔØ!1ˆÕr^   c                 óT   — | j                  ||| j                  | j                  ¬«      S ©N)rÞ   rß   rà   r[   )r]   rÝ   rP   )rT   rÞ   rß   s      r9   Úfrom_credentialsz#IDTokenCredentials.from_credentials<  s0   € Ø�~‰~Ø1Ø+Ø×-Ñ-Ø!×3Ñ3ð	 ó 
ð 	
r^   c                 óh   — | j                  | j                  || j                  | j                  ¬«      S râ   )r]   rÛ   rÝ   rP   )rT   rß   s     r9   Úwith_target_audiencez'IDTokenCredentials.with_target_audienceD  s6   € Ø�~‰~Ø#×7Ñ7Ø+Ø×-Ñ-Ø!×3Ñ3ð	 ó 
ð 	
r^   c                 óh   — | j                  | j                  | j                  || j                  ¬«      S râ   )r]   rÛ   rÜ   rP   )rT   rà   s     r9   Úwith_include_emailz%IDTokenCredentials.with_include_emailL  s6   € Ø�~‰~Ø#×7Ñ7Ø ×1Ñ1Ø'Ø!×3Ñ3ð	 ó 
ð 	
r^   c                 óh   — | j                  | j                  | j                  | j                  |¬«      S râ   )r]   rÛ   rÜ   rÝ   )rT   r[   s     r9   r®   z%IDTokenCredentials.with_quota_projectT  s6   € à�~‰~Ø#×7Ñ7Ø ×1Ñ1Ø×-Ñ-Ø-ð	 ó 
ð 	
r^   c                 ó*  — ddl m} t        j                  j	                  t
        j                  | j                  j                  «      j                  | j                  j                  «      }| j                  | j                  j                  | j                  dœ}ddt        j                  t        j                   «       i} || j                  j"                  |¬«      }	 |j%                  ||t'        j(                  |«      j+                  d«      ¬«      }|j-                  «        |j.                  t0        j2                  k7  r2t5        j6                  d	j                  |j'                  «       «      «      ‚	 |j'                  «       d
   }|| _        t?        j@                  tC        jD                  |d¬«      d   «      | _#        y # |j-                  «        w xY w# t8        t:        f$ r,}	t5        j6                  d|j'                  «       «      }
|
|	‚d }	~	ww xY w)Nr   rˆ   )ÚaudiencerX   ÚincludeEmailrg   rh   )Úauth_requestr   )r   r   r#   zError getting ID token: {}r5   zNo ID token in response.F)Úverifyrn   )$r‹   r‰   r	   Ú_IAM_IDTOKEN_ENDPOINTr   r   r   rÛ   r/   r   r�   rÜ   rK   rÝ   r   rv   Ú"token_request_id_token_impersonaterB   r�   r   r    r!   r•   r‘   r%   r&   r   r'   r+   r,   r5   r   Úutcfromtimestampr
   r   r6   )rT   r-   r‰   r—   r   r   r˜   r2   Úid_tokenr7   r8   s              r9   rt   zIDTokenCredentials.refresh]  sÄ  € åDä×5Ñ5×=Ñ=Ü×/Ñ/Ø×$Ñ$×4Ñ4ó
÷ ‰&�×)Ñ)×6Ñ6Ó
7ð 	ð ×-Ñ-Ø×1Ñ1×<Ñ<Ø ×/Ñ/ñ
ˆð Ð.Ü×%Ñ%¤w×'QÑ'QÓ'Sð
ˆñ
 +Ø×$Ñ$×8Ñ8Àwô
ˆð	#Ø%×*Ñ*Ø%ØÜ—Z‘Z Ó%×,Ñ,¨WÓ5ð +ó ˆHð × Ñ Ô"à×Ñ¤;§>¡>Ò1Ü×)Ñ)Ø,×3Ñ3°H·M±M³OÓDóð ð	*Ø—}‘}“ wÑ/ˆHð ˆŒ
Ü×/Ñ/Ü�J‰J�x¨Ô.¨uÑ5ó
ˆ�øð! × Ñ Õ"ûô œ*Ð%ò 	*Ü ×-Ñ-Ø*¨H¯M©M«OóˆGð ˜zÐ)ûð		*ús$   Ã6G Å5G ÇGÇHÇ&'HÈH)NFNr`   )rÍ   rÎ   rÏ   rÐ   r@   rã   rå   rç   r   rÒ   r   rÔ   r®   r<   rt   rÖ   r×   s   @r9   rÙ   rÙ     st   ø„ ÙEð
 ØØõ2ó6
ò
ò
ð €X×Ñ˜[×DÑDÓEñ
ó Fð
ð €X×Ñ˜[×4Ñ4Ó5ñ0
ó 6ô0
r^   rÙ   c                 óx  — t         j                  j                  |«      }|t        j                  |«      dœ}t        j                  |«      j                  d«      } | |d||¬«      }t        |j                  d«      r|j                  j                  d«      n|j                  }|j                  t        j                  k7  rt        j                  t        |«      ‚	 t        j                  |«      }	|	d   }
|
S # t         t"        f$ r1}t        j                  dj                  t        «      |«      }||‚d}~ww xY w)	aû  Makes a request to the Google Cloud IAM service to sign a JWT using a
    service account's system-managed private key.
    Args:
        request (Request): The Request object to use.
        principal (str): The principal to request an access token for.
        headers (Mapping[str, str]): Map of headers to transmit.
        payload (Mapping[str, str]): The JWT payload to sign. Must be a
            serialized JSON object that contains a JWT Claims Set.
        delegates (Sequence[str]): The chained list of delegates required
            to grant the final access_token.  If set, the sequence of
            identities must have "Service Account Token Creator" capability
            granted to the prceeding identity.  For example, if set to
            [serviceAccountB, serviceAccountC], the source_credential
            must have the Token Creator role on serviceAccountB.
            serviceAccountB must have the Token Creator on
            serviceAccountC.
            Finally, C must have Token Creator on target_principal.
            If left unset, source_credential must have that role on
            target_principal.

    Raises:
        google.auth.exceptions.TransportError: Raised if there is an underlying
            HTTP connection error
        google.auth.exceptions.RefreshError: Raised if the impersonated
            credentials are not available.  Common reasons are
            `iamcredentials.googleapis.com` is not enabled or the
            `Service Account Token Creator` is not assigned
    )rX   ro   r   r   r   r   Ú	signedJwtz{}: No signed JWT in response.N)r	   Ú_IAM_SIGNJWT_ENDPOINTr   r   r    r!   r"   r#   r   r$   r%   r&   r   r'   r(   r)   r+   r,   )r-   r.   r   ro   rX   r1   r   r2   r3   Újwt_responseÚ
signed_jwtr7   r8   s                r9   r}   r}   ‘  s  € ô: ×,Ñ,×3Ñ3°IÓ>€Là"¬t¯z©z¸'Ó/BÑC€DÜ�:‰:�dÓ×"Ñ" 7Ó+€Dá˜<°ÀÈdÔS€Hô
 �8—=‘= (Ô+ð 	�‰×Ñ˜WÔ%à�]‰]ð ð ‡�œ+Ÿ.™.Ò(Ü×%Ñ%¤n°mÓDÐDð	&Ü—z‘z -Ó0ˆØ! +Ñ.ˆ
ØÐøä”jÐ!ò &Ü×)Ñ)Ø,×3Ñ3´NÓCÀ]ó
ˆð ˜:Ð%ûð	&ús   ÃC9 Ã9D9Ä,D4Ä4D9)"rÐ   r�   rA   r   Úhttp.clientÚclientr%   r   r¿   r   r   r   r   r	   r
   r   rº   r   r(   rM   r{   r…   r¹   r¼   r¾   r   r:   rD   rÔ   ÚSigningrÓ   r<   rÙ   r}   ri   r^   r9   ú<module>rú      sÊ   ðñó Û Ý Ý !Û å ,Ý  Ý #Ý "Ý Ý Ý Ý !ð >€à#Ð à EÐ àQð  ð +<Ð 'Ø*;Ð 'à&ð 9ð  ×7Ñ7Øó;&ô|a
Ø×ÑØ×+Ñ+Ø×ÑØ×,Ñ,ô	a
ôHp
˜×@Ñ@ô p
ðf GIô 7&r^   