
    (phQa                        S r SSKJr  SSKrSSKrSSKrSSKrSSKJr  SSKJr  SSKJ	r	  SSKJ
r
  SSKJr  SS	KJr  \R                  " \5      rS
rSr " S S\	R&                  \	R(                  5      r " S S\	R(                  5      rg)a  OAuth 2.0 Credentials.

This module provides credentials based on OAuth 2.0 access and refresh tokens.
These credentials usually access resources on behalf of a user (resource
owner).

Specifically, this is intended to use access tokens acquired using the
`Authorization Code grant`_ and can refresh those tokens using a
optional `refresh token`_.

Obtaining the initial access and refresh token is outside of the scope of this
module. Consult `rfc6749 section 4.1`_ for complete details on the
Authorization Code grant flow.

.. _Authorization Code grant: https://tools.ietf.org/html/rfc6749#section-1.3.1
.. _refresh token: https://tools.ietf.org/html/rfc6749#section-6
.. _rfc6749 section 4.1: https://tools.ietf.org/html/rfc6749#section-4.1
    )datetimeN)
_cloud_sdk)_helpers)credentials)
exceptions)metrics)reauthz#https://oauth2.googleapis.com/tokenz'https://oauth2.googleapis.com/tokeninfoc                     ^  \ rS rSrSrSSSSSSSSSSSSSS\R                  S4U 4S jjrS rS r	\
S 5       r\
S	 5       r\
S
 5       r\
S 5       r\
S 5       r\
S 5       r\
S 5       r\
S 5       r\
S 5       r\
S 5       r\R*                  S 5       r\
S 5       rS r\R2                  " \R4                  5      S 5       r\R2                  " \R8                  5      S 5       r\R2                  " \R<                  5      S 5       rS r \R2                  " \RB                  5      S 5       r"S r#\R2                  " \R4                  5      S 5       r$\%S S j5       r&\%S S j5       r'S S jr(Sr)U =r*$ )!Credentials9   a  Credentials using OAuth 2.0 access and refresh tokens.

The credentials are considered immutable except the tokens and the token
expiry, which are updated after refresh. If you want to modify the quota
project, use :meth:`with_quota_project` or ::

    credentials = credentials.with_quota_project('myproject-123')

Reauth is disabled by default. To enable reauth, set the
`enable_reauth_refresh` parameter to True in the constructor. Note that
reauth feature is intended for gcloud to use only.
If reauth is enabled, `pyu2f` dependency has to be installed in order to use security
key reauth feature. Dependency can be installed via `pip install pyu2f` or `pip install
google-auth[reauth]`.
NFc                 H  > [         [        U ]  5         Xl        Xl        X l        X0l        Xpl        Xl        Xl	        X@l
        XPl        X`l        Xl        Xl        Xl        Xl        Xl        U=(       d    [$        R&                  U l        U=(       d    SU l        SU l        g)a
  
Args:
    token (Optional(str)): The OAuth 2.0 access token. Can be None
        if refresh information is provided.
    refresh_token (str): The OAuth 2.0 refresh token. If specified,
        credentials can be refreshed.
    id_token (str): The Open ID Connect ID Token.
    token_uri (str): The OAuth 2.0 authorization server's token
        endpoint URI. Must be specified for refresh, can be left as
        None if the token can not be refreshed.
    client_id (str): The OAuth 2.0 client ID. Must be specified for
        refresh, can be left as None if the token can not be refreshed.
    client_secret(str): The OAuth 2.0 client secret. Must be specified
        for refresh, can be left as None if the token can not be
        refreshed.
    scopes (Sequence[str]): The scopes used to obtain authorization.
        This parameter is used by :meth:`has_scopes`. OAuth 2.0
        credentials can not request additional scopes after
        authorization. The scopes must be derivable from the refresh
        token if refresh information is provided (e.g. The refresh
        token scopes are a superset of this or contain a wild card
        scope like 'https://www.googleapis.com/auth/any-api').
    default_scopes (Sequence[str]): Default scopes passed by a
        Google client library. Use 'scopes' for user-defined scopes.
    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.
    rapt_token (Optional[str]): The reauth Proof Token.
    refresh_handler (Optional[Callable[[google.auth.transport.Request, Sequence[str]], [str, datetime]]]):
        A callable which takes in the HTTP request callable and the list of
        OAuth scopes and when called returns an access token string for the
        requested scopes and its expiry datetime. This is useful when no
        refresh tokens are provided and tokens are obtained by calling
        some external process on demand. It is particularly useful for
        retrieving downscoped tokens from a token broker.
    enable_reauth_refresh (Optional[bool]): Whether reauth refresh flow
        should be used. This flag is for gcloud to use only.
    granted_scopes (Optional[Sequence[str]]): The scopes that were consented/granted by the user.
        This could be different from the requested scopes and it could be empty if granted
        and requested scopes were same.
    trust_boundary (str): String representation of trust boundary meta.
    universe_domain (Optional[str]): The universe domain. The default
        universe domain is googleapis.com.
    account (Optional[str]): The account associated with the credential.
 N)superr   __init__tokenexpiry_refresh_token	_id_token_scopes_default_scopes_granted_scopes
_token_uri
_client_id_client_secret_quota_project_id_rapt_tokenrefresh_handler_enable_reauth_refresh_trust_boundaryr   DEFAULT_UNIVERSE_DOMAIN_universe_domain_account_cred_file_path)selfr   refresh_tokenid_token	token_uri	client_idclient_secretscopesdefault_scopesquota_project_idr   
rapt_tokenr   enable_reauth_refreshgranted_scopestrust_boundaryuniverse_domainaccount	__class__s                     L/var/www/html/venv/lib/python3.13/site-packages/google/oauth2/credentials.pyr   Credentials.__init__J   s    B 	k4)+
+!--##+!1%.&;#- / V;3V3V2#    c                 ^    U R                   R                  5       nSU;   a  US	 SU;   a  US	 U$ )zA __getstate__ method must exist for the __setstate__ to be called
This is identical to the default implementation.
See https://docs.python.org/3.7/library/pickle.html#object.__setstate__
_refresh_handler_refresh_worker)__dict__copy)r$   
state_dicts     r4   __getstate__Credentials.__getstate__   s@    
 ]]'')

 +-.
*,-r6   c                 j   UR                  S5      U l        UR                  S5      U l        UR                  S5      U l        UR                  S5      U l        UR                  S5      U l        UR                  S5      U l        UR                  S5      U l        UR                  S5      U l        UR                  S	5      U l	        UR                  S
5      U l
        UR                  S5      U l        UR                  S5      U l        UR                  S5      U l        UR                  S5      U l        UR                  S5      =(       d    [        R                   U l        UR                  S5      U l        SU l        SU l        UR                  SS5      U l        UR                  SS5      U l        g)zTCredentials pickled with older versions of the class do not have
all the attributes.r   r   r   r   r   r   r   r   r   r   r   r   r   r   r!   r#   N_use_non_blocking_refreshFr"   r   )getr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r#   r8   r9   r@   r"   )r$   ds     r4   __setstate__Credentials.__setstate__   s[    UU7^
eeHoee$45{+uuY' uu%67 uu%67%%-%%-ee$45!"':!;55/&'ee,D&E# uu%67EE$%L)L)L 	  !uu%67 $#)*/JE)R&j"-r6   c                     U R                   $ )z+Optional[str]: The OAuth 2.0 refresh token.)r   r$   s    r4   r%   Credentials.refresh_token        """r6   c                     U R                   $ )z/Optional[str]: The OAuth 2.0 permission scopes.)r   rF   s    r4   r*   Credentials.scopes   s     ||r6   c                     U R                   $ )zWOptional[Sequence[str]]: The OAuth 2.0 permission scopes that were granted by the user.)r   rF   s    r4   r/   Credentials.granted_scopes   s     ###r6   c                     U R                   $ )zGOptional[str]: The OAuth 2.0 authorization server's token endpoint
URI.)r   rF   s    r4   r'   Credentials.token_uri   s     r6   c                     U R                   $ )a<  Optional[str]: The Open ID Connect ID Token.

Depending on the authorization server and the scopes requested, this
may be populated when credentials are obtained and updated when
:meth:`refresh` is called. This token is a JWT. It can be verified
and decoded using :func:`google.oauth2.id_token.verify_oauth2_token`.
)r   rF   s    r4   r&   Credentials.id_token   s     ~~r6   c                     U R                   $ )z'Optional[str]: The OAuth 2.0 client ID.)r   rF   s    r4   r(   Credentials.client_id   s     r6   c                     U R                   $ )z+Optional[str]: The OAuth 2.0 client secret.)r   rF   s    r4   r)   Credentials.client_secret   rH   r6   c                     g)znFalse: OAuth 2.0 credentials have their scopes set when
the initial token is requested and can not be changed.F rF   s    r4   requires_scopesCredentials.requires_scopes   s     r6   c                     U R                   $ )z&Optional[str]: The reauth Proof Token.)r   rF   s    r4   r-   Credentials.rapt_token   s     r6   c                     U R                   $ )zReturns the refresh handler if available.

Returns:
   Optional[Callable[[google.auth.transport.Request, Sequence[str]], [str, datetime]]]:
       The current refresh handler.
)r8   rF   s    r4   r   Credentials.refresh_handler   s     $$$r6   c                 L    [        U5      (       d  Ub  [        S5      eXl        g)zUpdates the current refresh handler.

Args:
    value (Optional[Callable[[google.auth.transport.Request, Sequence[str]], [str, datetime]]]):
        The updated value of the refresh handler.

Raises:
    TypeError: If the value is not a callable or None.
Nz7The provided refresh_handler is not a callable or None.)callable	TypeErrorr8   )r$   values     r4   r   r\   
  s$     5#4UVV %r6   c                     U R                   $ )zlstr: The user account associated with the credential. If the account is unknown an empty string is returned.)r"   rF   s    r4   r2   Credentials.account  s     }}r6   c                    U R                  U R                  U R                  U R                  U R                  U R
                  U R                  U R                  U R                  U R                  U R                  U R                  U R                  U R                  U R                  U R                  S9nU R                   Ul        U$ )N)r%   r&   r'   r(   r)   r*   r+   r/   r,   r-   r.   r0   r1   r2   )r3   r   r%   r&   r'   r(   r)   r*   r+   r/   r,   r-   r   r   r!   r"   r#   )r$   creds     r4   
_make_copyCredentials._make_copy  s    ~~JJ,,]]nnnn,,;;....!22"&"="=// 11MM  
"  $33r6   c                     U R                   (       a1  U R                   SS.nU R                  (       a  U R                  US'   U$ g )Nzuser credentials)credential_sourcecredential_type	principal)r#   r2   )r$   	cred_infos     r4   get_cred_infoCredentials.get_cred_info3  s>    %)%9%9#5I ||)-	+&r6   c                 2    U R                  5       nXl        U$ N)re   r   )r$   r,   rd   s      r4   with_quota_projectCredentials.with_quota_project?  s     !1r6   c                 2    U R                  5       nXl        U$ ro   )re   r   )r$   r'   rd   s      r4   with_token_uriCredentials.with_token_uriE  s     #r6   c                 2    U R                  5       nXl        U$ )zReturns a copy of these credentials with a modified account.

Args:
    account (str): The account to set

Returns:
    google.oauth2.credentials.Credentials: A new credentials instance.
)re   r"   )r$   r2   rd   s      r4   with_accountCredentials.with_accountK  s      r6   c                 2    U R                  5       nXl        U$ ro   )re   r!   )r$   r1   rd   s      r4   with_universe_domain Credentials.with_universe_domainX  s      /r6   c                 "    [         R                  $ ro   )r   CRED_TYPE_USERrF   s    r4   _metric_header_for_usage$Credentials._metric_header_for_usage^  s    %%%r6   c                 B   U R                   [        R                  :w  a/  [        R                  " SR                  U R                   5      5      eU R                  b  U R                  OU R                  nU R                  c  U R                  (       a  U R                  XS9u  p4[        U[        5      (       d  [        R                  " S5      e[        U[        5      (       d  [        R                  " S5      e[        R                  " 5       U[        R                  -
  :  a  [        R                  " S5      eX0l        X@l        g U R                  b'  U R$                  b  U R&                  b  U R(                  c  [        R                  " S5      e[*        R,                  " UU R$                  U R                  U R&                  U R(                  UU R.                  U R0                  S9u  nnnnnXPl        X@l        X`l        UR3                  S5      U l        Xl        U(       a  S	U;   ax  [7        U5      n	US	   R9                  5       U l        [7        U R:                  5      n
X-
  nU(       a4  [<        R?                  S
R                  SRA                  U5      5      5        g g g g )Na  User credential refresh is only supported in the default googleapis.com universe domain, but the current universe domain is {}. If you created the credential with an access token, it's likely that the provided token is expired now, please update your code with a valid token.)r*   z3The refresh_handler returned token is not a string.z=The refresh_handler returned expiry is not a datetime object.zDThe credentials returned by the refresh_handler are already expired.zThe credentials do not contain the necessary fields need to refresh the access token. You must specify refresh_token, token_uri, client_id, and client_secret.)r*   r-   r.   r&   scopezUNot all requested scopes were granted by the authorization server, missing scopes {}., )!r!   r   r    r   RefreshErrorformatr   r   r   r   
isinstancestrr   r   utcnowREFRESH_THRESHOLDr   r   r   r   r   r	   refresh_grantr   r   rA   r   	frozensetsplitr   _LOGGERwarningjoin)r$   requestr*   r   r   access_tokenr%   grant_responser-   requested_scopesr/    scopes_requested_but_not_granteds               r4   refreshCredentials.refresha  s`     K$G$GG))> ?Ef))?  "&!9t?S?S
 &4+?+? 000HMEeS)) --I  fh// --S   FX-G-G$GG --'  J K '&&""*));    OOOO''"&"="=	
	
 "
+'++J7%g/(0#1'#:#@#@#BD &t';';<N/?/P,/
 ??Ev		"BC@ 0 06r6   c                 ^   [        S5      nUR                  UR                  5       5      nU(       a)  [        SR	                  SR                  U5      5      5      eUR                  S5      nU(       a9  [        R                  " UR                  S5      R                  S5      S   S5      nO&[        R                  " 5       [        R                  -
  nUc=  S	U;   a7  UR                  S	5      n[        U[        5      (       a  UR                  S
5      nU " UR                  S5      UR                  S5      [         UUR                  S5      UR                  S5      UR                  S5      UUR                  S5      UR                  S5      UR                  S5      UR                  SS5      S9$ )a  Creates a Credentials instance from parsed authorized user info.

Args:
    info (Mapping[str, str]): The authorized user 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:
    ValueError: If the info is not in the expected format.
)r%   r(   r)   zGAuthorized user info was not in the expected format, missing fields {}.r   r   Z.r   z%Y-%m-%dT%H:%M:%Sr*    r   r%   r(   r)   r,   r-   r0   r1   r2   r   )r   r%   r'   r*   r(   r)   r,   r   r-   r0   r1   r2   )set
differencekeys
ValueErrorr   r   rA   r   strptimerstripr   r   r   r   r   r   _GOOGLE_OAUTH2_TOKEN_ENDPOINT)clsinfor*   keys_neededmissingr   s         r4   from_authorized_user_info%Credentials.from_authorized_user_info  sf   " IJ((5#VDIIg$67  (#&&c"((-a02EF __&)C)CCF >h$.XXh'F&#&&c*((7#((?33hh{+((?3!XX&89xx-88$45 HH%67HHY+
 	
r6   c                     [         R                  " USSS9 n[        R                  " U5      nU R	                  XB5      sSSS5        $ ! , (       d  f       g= f)a  Creates a Credentials instance from an authorized user json file.

Args:
    filename (str): The path to the authorized user json file.
    scopes (Sequence[str]): Optional list of scopes to include in the
        credentials.

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

Raises:
    ValueError: If the file is not in the expected format.
rzutf-8)encodingN)ioopenjsonloadr   )r   filenamer*   	json_filedatas        r4   from_authorized_user_file%Credentials.from_authorized_user_file  s>      WWXsW599Y'D00> 655s   'A
Ac           
      "   U R                   U R                  U R                  U R                  U R                  U R
                  U R                  U R                  U R                  S.	nU R                  (       a   U R                  R                  5       S-   US'   UR                  5        VVs0 s H  u  p4Uc  M
  X4_M     nnnUb+  UR                  5        VVs0 s H  u  p4X1;  d  M  X4_M     nnn[        R                  " U5      $ s  snnf s  snnf )a  Utility function that creates a JSON representation of a Credentials
object.

Args:
    strip (Sequence[str]): Optional list of members to exclude from the
                           generated JSON.

Returns:
    str: A JSON representation of this instance. When converted into
    a dictionary, it can be passed to from_authorized_user_info()
    to create a new credential instance.
)	r   r%   r'   r(   r)   r*   r-   r1   r2   r   r   )r   r%   r'   r(   r)   r*   r-   r!   r"   r   	isoformatitemsr   dumps)r$   stripprepkvs        r4   to_jsonCredentials.to_json  s     ZZ!//!//kk//#44}}

 ;;![[224s:DN "&?? %)ZZ\D\TQQ^DAD\DDzz$ @ Es   +	D8DD&D)r"   r   r   r#   r   r   r   r   r   r   r8   r   r9   r   r   r   r!   r@   r   r   r   ro   )+__name__
__module____qualname____firstlineno____doc__r   r    r   r=   rC   propertyr%   r*   r/   r'   r&   r(   r)   rW   r-   r   setterr2   re   r   copy_docstringr   rl   CredentialsWithQuotaProjectrp   CredentialsWithTokenUrirs   rv   CredentialsWithUniverseDomainry   r}   r   classmethodr   r   r   __static_attributes____classcell__r3   s   @r4   r   r   9   sH   & ##;;%S$j".6 # #   $ $  
     # #  
     % % & &  * [445	 6	 [DDE F
 [@@A B
 [FFG H
& [445W 6Wr 5
 5
n ? ?&"  " r6   r   c                      ^  \ rS rSrSrS	U 4S jjrS r\R                  " \	R                  5      S 5       rS r\R                  " \	R                  5      S 5       rSrU =r$ )
UserAccessTokenCredentialsi,  a  Access token credentials for user account.

Obtain the access token for a given user account or the current active
user account with the ``gcloud auth print-access-token`` command.

Args:
    account (Optional[str]): Account to get the access token for. If not
        specified, the current active account will be used.
    quota_project_id (Optional[str]): The project ID used for quota
        and billing.
c                 n   > [         R                  " S5        [        [        U ]  5         Xl        X l        g )NzUserAccessTokenCredentials is deprecated, please use google.oauth2.credentials.Credentials instead. To use that credential type, simply run `gcloud auth application-default login` and let the client libraries pick up the application default credentials.)warningswarnr   r   r   r"   r   )r$   r2   r,   r3   s      r4   r   #UserAccessTokenCredentials.__init__9  s0    L	
 	($8:!1r6   c                 4    U R                  XR                  S9$ )zCreate a new instance with the given account.

Args:
    account (str): Account to get the access token for.

Returns:
    google.oauth2.credentials.UserAccessTokenCredentials: The created
        credentials with the given account.
r2   r,   )r3   r   )r$   r2   s     r4   rv   'UserAccessTokenCredentials.with_accountE  s     ~~g@V@V~WWr6   c                 6    U R                  U R                  US9$ )Nr   )r3   r"   )r$   r,   s     r4   rp   -UserAccessTokenCredentials.with_quota_projectQ  s    ~~dmmFV~WWr6   c                 N    [         R                  " U R                  5      U l        g)a;  Refreshes the access token.

Args:
    request (google.auth.transport.Request): This argument is required
        by the base class interface but not used in this implementation,
        so just set it to `None`.

Raises:
    google.auth.exceptions.UserAccessTokenError: If the access token
        refresh failed.
N)r   get_auth_access_tokenr"   r   )r$   r   s     r4   r   "UserAccessTokenCredentials.refreshU  s      55dmmD
r6   c                 H    U R                  U5        U R                  U5        g ro   )r   apply)r$   r   methodurlheaderss        r4   before_request)UserAccessTokenCredentials.before_requestc  s    W

7r6   )r"   r   r   )NN)r   r   r   r   r   r   rv   r   r   r   r   rp   r   r   r   r   r   r   s   @r4   r   r   ,  sf    

2
X [DDEX FXE [445 6r6   r   )r   r   r   r   loggingr   google.authr   r   r   r   r   google.oauth2r	   	getLoggerr   r   r   "_GOOGLE_OAUTH2_TOKEN_INFO_ENDPOINTReadOnlyScopedr   r   r   rV   r6   r4   <module>r      s~   &  	    "   # "   


H
% !F  &O "p +,,k.U.U p f:!H!H :r6   