
    (phI                     X   S r SSKrSSKJr  SSKrSSKJrJr  SSKJr  SSKJ	r	  SSK
Jr  SSKJr  S	r " S
 S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\R(                  S9r " S S\5      rSS jr " S S\R(                  S9r " S S\5      rg)zInterfaces for credentials.    N)Enum)_helpersenvironment_vars)
exceptions)metrics)_BaseCredentials)RefreshThreadManagerzgoogleapis.comc                      ^  \ rS rSrSrU 4S jr\S 5       r\S 5       r\S 5       r	\S 5       r
\S 5       rS	 r\R                  S
 5       rS rSS jrS rS rS rS rSrU =r$ )Credentials   a  Base class for all credentials.

All credentials have a :attr:`token` that is used for authentication and
may also optionally set an :attr:`expiry` to indicate when the token will
no longer be valid.

Most credentials will be :attr:`invalid` until :meth:`refresh` is called.
Credentials can do this automatically before the first HTTP request in
:meth:`before_request`.

Although the token and expiration will change as the credentials are
:meth:`refreshed <refresh>` and used, credentials should be considered
immutable. Various credentials will accept configuration such as private
keys, scopes, and other options. These options are not changeable after
construction. Some classes will provide mechanisms to copy the credentials
with modifications such as :meth:`ScopedCredentials.with_scopes`.
c                    > [         [        U ]  5         S U l         S U l         S U l         [        U l         SU l        [        5       U l
        g NF)superr   __init__expiry_quota_project_id_trust_boundaryDEFAULT_UNIVERSE_DOMAIN_universe_domain_use_non_blocking_refreshr	   _refresh_workerself	__class__s    J/var/www/html/venv/lib/python3.13/site-packages/google/auth/credentials.pyr   Credentials.__init__2   sY    k4)+	B!%K#	 !8	 */&35    c                     U R                   (       d  gU R                   [        R                  -
  n[        R                  " 5       U:  $ )zChecks if the credentials are expired.

Note that credentials can be invalid but not expired because
Credentials with :attr:`expiry` set to None is considered to never
expire.

.. deprecated:: v2.24.0
  Prefer checking :attr:`token_state` instead.
F)r   r   REFRESH_THRESHOLDutcnow)r   skewed_expirys     r   expiredCredentials.expiredE   s6     {{ h&@&@@ M11r   c                 N    U R                   SL=(       a    U R                  (       + $ )zChecks the validity of the credentials.

This is True if the credentials have a :attr:`token` and the token
is not :attr:`expired`.

.. deprecated:: v2.24.0
  Prefer checking :attr:`token_state` instead.
N)tokenr"   r   s    r   validCredentials.validW   s     zz%:dll*::r   c                    U R                   c  [        R                  $ U R                  c  [        R                  $ [
        R                  " 5       U R                  :  nU(       a  [        R                  $ [
        R                  " 5       U R                  [
        R                  -
  :  nU(       a  [        R                  $ [        R                  $ )z
See `:obj:`TokenState`
)	r%   
TokenStateINVALIDr   FRESHr   r    r   STALE)r   r"   is_stales      r   token_stateCredentials.token_statec   s    
 ::%%% ;;###//#t{{2%%%??$x7Q7Q)QR###r   c                     U R                   $ )z.Project to use for quota and billing purposes.)r   r&   s    r   quota_project_idCredentials.quota_project_idy   s     %%%r   c                     U R                   $ )zThe universe domain value.)r   r&   s    r   universe_domainCredentials.universe_domain~   s     $$$r   c                     g)zThe credential information JSON.

The credential information will be added to auth related error messages
by client library.

Returns:
    Mapping[str, str]: The credential information JSON.
N r&   s    r   get_cred_infoCredentials.get_cred_info   s     r   c                     [        S5      e)zRefreshes the access token.

Args:
    request (google.auth.transport.Request): The object used to make
        HTTP requests.

Raises:
    google.auth.exceptions.RefreshError: If the credentials could
        not be refreshed.
zRefresh must be implementedNotImplementedErrorr   requests     r   refreshCredentials.refresh   s     ""?@@r   c                     g)a  The x-goog-api-client header for token usage metric.

This header will be added to the API service requests in before_request
method. For example, "cred-type/sa-jwt" means service account self
signed jwt access token is used in the API service request
authorization header. Children credentials classes need to override
this method to provide the header value, if the token usage metric is
needed.

Returns:
    str: The x-goog-api-client header value.
Nr8   r&   s    r   _metric_header_for_usage$Credentials._metric_header_for_usage   s     r   c                     U R                  XS9   U R                  b  U R                  S   US'   U R                  (       a  U R                  US'   gg)zApply the token to the authentication header.

Args:
    headers (Mapping): The HTTP request headers.
    token (Optional[str]): If specified, overrides the current access
        token.
)r%   Nencoded_locationszx-allowed-locationszx-goog-user-project)_applyr   r2   r   headersr%   s      r   applyCredentials.apply   s[     	G)	 +-1-A-ABU-VG)*  -1-B-BG)* !r   c                 J    U R                   (       d  U R                  U5        g g N)r'   r@   r>   s     r   _blocking_refreshCredentials._blocking_refresh   s    zzLL! r   c                 &   SnU R                   [        R                  :X  a   U R                  R	                  X5      (       + nU R                   [        R
                  :X  d  U(       a,  U R                  U5        U R                  R                  5         g g r   )r/   r*   r-   r   start_refreshr+   r@   clear_error)r   r?   use_blocking_refresh_fallbacks      r   _non_blocking_refresh!Credentials._non_blocking_refresh   sz    (-%z///040D0D0R0R1 -) z1115RLL!   ,,. 6Sr   c                     U R                   (       a  U R                  U5        OU R                  U5        [        R                  " X@R                  5       5        U R                  U5        g)a  Performs credential-specific before request logic.

Refreshes the credentials if necessary, then calls :meth:`apply` to
apply the token to the authentication header.

Args:
    request (google.auth.transport.Request): The object used to make
        HTTP requests.
    method (str): The request's HTTP method or the RPC method being
        invoked.
    url (str): The request's URI or the RPC service's URI.
    headers (Mapping): The request's headers.
N)r   rT   rN   r   add_metric_headerrC   rJ   r   r?   methodurlrI   s        r   before_requestCredentials.before_request   sL    " ))&&w/""7+!!'+H+H+JK

7r   c                     SU l         g )NT)r   r&   s    r   with_non_blocking_refresh%Credentials.with_non_blocking_refresh   s
    )-&r   )r   r   r   r   r   r   rM   )__name__
__module____qualname____firstlineno____doc__r   propertyr"   r'   r/   r2   r5   r9   abcabstractmethodr@   rC   rJ   rN   rT   r[   r^   __static_attributes____classcell__r   s   @r   r   r      s    $6& 2 2" 	; 	;    * & & % %	 	A AC6"/2. .r   r   c                   $    \ rS rSrSrS rS rSrg)CredentialsWithQuotaProject   zGAbstract base for credentials supporting ``with_quota_project`` factoryc                     [        S5      e)zReturns a copy of these credentials with a modified quota project.

Args:
    quota_project_id (str): The project to use for quota and
        billing purposes

Returns:
    google.auth.credentials.Credentials: A new credentials instance.
z/This credential does not support quota project.r<   )r   r2   s     r   with_quota_project.CredentialsWithQuotaProject.with_quota_project   s     ""STTr   c                     [         R                  R                  [        R                  5      nU(       a  U R                  U5      $ U $ rM   )osenvirongetr   GOOGLE_CLOUD_QUOTA_PROJECTro   )r   quota_from_envs     r   #with_quota_project_from_environment?CredentialsWithQuotaProject.with_quota_project_from_environment  s4    (8(S(ST**>::r   r8   N)r`   ra   rb   rc   rd   ro   rw   rh   r8   r   r   rl   rl      s    Q
Ur   rl   c                       \ rS rSrSrS rSrg)CredentialsWithTokenUrii  zCAbstract base for credentials supporting ``with_token_uri`` factoryc                     [        S5      e)zReturns a copy of these credentials with a modified token uri.

Args:
    token_uri (str): The uri to use for fetching/exchanging tokens

Returns:
    google.auth.credentials.Credentials: A new credentials instance.
z'This credential does not use token uri.r<   )r   	token_uris     r   with_token_uri&CredentialsWithTokenUri.with_token_uri  s     ""KLLr   r8   N)r`   ra   rb   rc   rd   r}   rh   r8   r   r   rz   rz     s    M	Mr   rz   c                       \ rS rSrSrS rSrg)CredentialsWithUniverseDomaini  zIAbstract base for credentials supporting ``with_universe_domain`` factoryc                     [        S5      e)zReturns a copy of these credentials with a modified universe domain.

Args:
    universe_domain (str): The universe domain to use

Returns:
    google.auth.credentials.Credentials: A new credentials instance.
z6This credential does not support with_universe_domain.r<   )r   r5   s     r   with_universe_domain2CredentialsWithUniverseDomain.with_universe_domain   s     "D
 	
r   r8   N)r`   ra   rb   rc   rd   r   rh   r8   r   r   r   r     s
    S
r   r   c                   N    \ rS rSrSr\S 5       r\S 5       rS rS
S jr	S r
S	rg)AnonymousCredentialsi.  zCredentials that do not provide any authentication information.

These are useful in the case of services that support anonymous access or
local service emulators that do not use credentials.
c                     g)z4Returns `False`, anonymous credentials never expire.Fr8   r&   s    r   r"   AnonymousCredentials.expired5  s     r   c                     g)z7Returns `True`, anonymous credentials are always valid.Tr8   r&   s    r   r'   AnonymousCredentials.valid:  s     r   c                 .    [         R                  " S5      e)zNRaises :class:``InvalidOperation``, anonymous credentials cannot be
refreshed.z*Anonymous credentials cannot be refreshed.)r   InvalidOperationr>   s     r   r@   AnonymousCredentials.refresh?  s     ))*VWWr   Nc                 6    Ub  [         R                  " S5      eg)zAnonymous credentials do nothing to the request.

The optional ``token`` argument is not supported.

Raises:
    google.auth.exceptions.InvalidValue: If a token was specified.
Nz+Anonymous credentials don't support tokens.)r   InvalidValuerH   s      r   rJ   AnonymousCredentials.applyD  s!     ))*WXX r   c                     g)z0Anonymous credentials do nothing to the request.Nr8   rX   s        r   r[   #AnonymousCredentials.before_requestO  s    r   r8   rM   )r`   ra   rb   rc   rd   re   r"   r'   r@   rJ   r[   rh   r8   r   r   r   r   .  s@        X
	Y?r   r   c                   v   ^  \ rS rSrSrU 4S jr\S 5       r\S 5       r\	R                  S 5       rS rSrU =r$ )	ReadOnlyScopediS  a  Interface for credentials whose scopes can be queried.

OAuth 2.0-based credentials allow limiting access using scopes as described
in `RFC6749 Section 3.3`_.
If a credential class implements this interface then the credentials either
use scopes in their implementation.

Some credentials require scopes in order to obtain a token. You can check
if scoping is necessary with :attr:`requires_scopes`::

    if credentials.requires_scopes:
        # Scoping is required.
        credentials = credentials.with_scopes(scopes=['one', 'two'])

Credentials that require scopes must either be constructed with scopes::

    credentials = SomeScopedCredentials(scopes=['one', 'two'])

Or must copy an existing instance using :meth:`with_scopes`::

    scoped_credentials = credentials.with_scopes(scopes=['one', 'two'])

Some credentials have scopes but do not allow or require scopes to be set,
these credentials can be used as-is.

.. _RFC6749 Section 3.3: https://tools.ietf.org/html/rfc6749#section-3.3
c                 F   > [         [        U ]  5         S U l        S U l        g rM   )r   r   r   _scopes_default_scopesr   s    r   r   ReadOnlyScoped.__init__p  s    nd,.#r   c                     U R                   $ )z6Sequence[str]: the credentials' current set of scopes.)r   r&   s    r   scopesReadOnlyScoped.scopesu  s     ||r   c                     U R                   $ )z>Sequence[str]: the credentials' current set of default scopes.)r   r&   s    r   default_scopesReadOnlyScoped.default_scopesz  s     ###r   c                     g)zLTrue if these credentials require scopes to obtain an access token.
        Fr8   r&   s    r   requires_scopesReadOnlyScoped.requires_scopes  s     r   c                     U R                   b  U R                   OU R                  n[        U5      R                  [        U=(       d    / 5      5      $ )a'  Checks if the credentials have the given scopes.

.. warning: This method is not guaranteed to be accurate if the
    credentials are :attr:`~Credentials.invalid`.

Args:
    scopes (Sequence[str]): The list of scopes to check.

Returns:
    bool: True if the credentials have the given scopes.
)r   r   setissubset)r   r   credential_scopess      r   
has_scopesReadOnlyScoped.has_scopes  sC     !LL4DLL$:N:N 	 6{##C(9(?R$@AAr   )r   r   )r`   ra   rb   rc   rd   r   re   r   r   rf   abstractpropertyr   r   rh   ri   rj   s   @r   r   r   S  s[    8$
   $ $ 	 
B Br   r   )	metaclassc                   @    \ rS rSrSr\R                  SS j5       rSrg)Scopedi  a  Interface for credentials whose scopes can be replaced while copying.

OAuth 2.0-based credentials allow limiting access using scopes as described
in `RFC6749 Section 3.3`_.
If a credential class implements this interface then the credentials either
use scopes in their implementation.

Some credentials require scopes in order to obtain a token. You can check
if scoping is necessary with :attr:`requires_scopes`::

    if credentials.requires_scopes:
        # Scoping is required.
        credentials = credentials.create_scoped(['one', 'two'])

Credentials that require scopes must either be constructed with scopes::

    credentials = SomeScopedCredentials(scopes=['one', 'two'])

Or must copy an existing instance using :meth:`with_scopes`::

    scoped_credentials = credentials.with_scopes(scopes=['one', 'two'])

Some credentials have scopes but do not allow or require scopes to be set,
these credentials can be used as-is.

.. _RFC6749 Section 3.3: https://tools.ietf.org/html/rfc6749#section-3.3
Nc                     [        S5      e)aW  Create a copy of these credentials with the specified scopes.

Args:
    scopes (Sequence[str]): The list of scopes to attach to the
        current credentials.

Raises:
    NotImplementedError: If the credentials' scopes can not be changed.
        This can be avoided by checking :attr:`requires_scopes` before
        calling this method.
z$This class does not require scoping.r<   )r   r   r   s      r   with_scopesScoped.with_scopes  s     ""HIIr   r8   rM   )	r`   ra   rb   rc   rd   rf   rg   r   rh   r8   r   r   r   r     s#    8 	J Jr   r   c                 p    [        U [        5      (       a   U R                  (       a  U R                  XS9$ U $ )a{  Creates a copy of the credentials with scopes if scoping is required.

This helper function is useful when you do not know (or care to know) the
specific type of credentials you are using (such as when you use
:func:`google.auth.default`). This function will call
:meth:`Scoped.with_scopes` if the credentials are scoped credentials and if
the credentials require scoping. Otherwise, it will return the credentials
as-is.

Args:
    credentials (google.auth.credentials.Credentials): The credentials to
        scope if necessary.
    scopes (Sequence[str]): The list of scopes to use.
    default_scopes (Sequence[str]): Default scopes passed by a
        Google client library. Use 'scopes' for user-defined scopes.

Returns:
    google.auth.credentials.Credentials: Either a new set of scoped
        credentials, or the passed in credentials instance if no scoping
        was required.
)r   )
isinstancer   r   r   )credentialsr   r   s      r   with_scopes_if_requiredr     s3    , +v&&;+F+F&&v&MMr   c                       \ rS rSrSr\R                  S 5       r\R                  S 5       r	\R                  S 5       r
Srg)Signingi  zCInterface for credentials that can cryptographically sign messages.c                     [        S5      e)zSigns the given message.

Args:
    message (bytes): The message to sign.

Returns:
    bytes: The message's cryptographic signature.
zSign bytes must be implemented.r<   )r   messages     r   
sign_bytesSigning.sign_bytes  s     ""CDDr   c                     [        S5      e)z;Optional[str]: An email address that identifies the signer.z!Signer email must be implemented.r<   r&   s    r   signer_emailSigning.signer_email  s    
 ""EFFr   c                     [        S5      e)z8google.auth.crypt.Signer: The signer used to sign bytes.zSigner must be implemented.r<   r&   s    r   signerSigning.signer  s    
 ""?@@r   r8   N)r`   ra   rb   rc   rd   rf   rg   r   r   r   r   rh   r8   r   r   r   r     sW    ME E 	G G 	A Ar   r   c                   $    \ rS rSrSrSrSrSrSrg)r*   i   a6  
Tracks the state of a token.
FRESH: The token is valid. It is not expired or close to expired, or the token has no expiry.
STALE: The token is close to expired, and should be refreshed. The token can be used normally.
INVALID: The token is expired or invalid. The token cannot be used for a normal operation.
         r8   N)	r`   ra   rb   rc   rd   r,   r-   r+   rh   r8   r   r   r*   r*      s     EEGr   r*   rM   )rd   rf   enumr   rr   google.authr   r   r   r   google.auth._credentials_baser   google.auth._refresh_workerr	   r   r   rl   rz   r   r   ABCMetar   r   r   r   r*   r8   r   r   <module>r      s     " 
  	 2 "  : <* V." V.r+ ,Mk M
K 
""?; "?JABs{{ ABH*J^ *JZ8A A@
 
r   