§
    9?Äj•  ã                   ó`   — d Z ddlZddlZddlZddlZddlmZ  ed¦  «        Z	d„ Z
d„ Zdd„ZdS )	a  Integration helpers.

This module provides helpers for integrating with `requests-oauthlib`_.
Typically, you'll want to use the higher-level helpers in
:mod:`google_auth_oauthlib.flow`.

.. _requests-oauthlib: http://requests-oauthlib.readthedocs.io/en/latest/
é    N)Ú external_account_authorized_user)Úauth_uriÚ	token_uriÚ	client_idc                 ó  — d| v r	| d         }nd| v r	| d         }nt          d¦  «        ‚t                               |                     ¦   «         ¦  «        st          d¦  «        ‚t	          j        d|d         |dœ|¤Ž}|| fS )aK  Creates a :class:`requests_oauthlib.OAuth2Session` from client
    configuration loaded from a Google-format client secrets file.

    Args:
        client_config (Mapping[str, Any]): The client
            configuration in the Google `client secrets`_ format.
        scopes (Sequence[str]): The list of scopes to request during the
            flow.
        kwargs: Any additional parameters passed to
            :class:`requests_oauthlib.OAuth2Session`

    Raises:
        ValueError: If the client configuration is not in the correct
            format.

    Returns:
        Tuple[requests_oauthlib.OAuth2Session, Mapping[str, Any]]: The new
            oauthlib session and the validated client configuration.

    .. _client secrets:
        https://github.com/googleapis/google-api-python-client/blob/main/docs/client-secrets.md
    ÚwebÚ	installedz2Client secrets must be for a web or installed app.z,Client secrets is not in the correct format.r   )r   Úscope© )Ú
ValueErrorÚ_REQUIRED_CONFIG_KEYSÚissubsetÚkeysÚrequests_oauthlibÚOAuth2Session)Úclient_configÚscopesÚkwargsÚconfigÚsessions        úMC:\Projects\Historical\venv\Lib\site-packages\google_auth_oauthlib/helpers.pyÚsession_from_client_configr   "   sª   € ð0 �ÐÐØ˜uÔ%ˆˆØ	˜Ð	%Ð	%Ø˜{Ô+ˆˆåÐMÑNÔNÐNå ×)Ò)¨&¯+ª+©-¬-Ñ8Ô8ð IÝÐGÑHÔHÐHåÔ-ð Ø˜Ô%¨Vðð Ø7=ðð €Gð �MÐ!Ð!ó    c                 ó–   — t          | d¦  «        5 }t          j        |¦  «        }ddd¦  «         n# 1 swxY w Y   t          ||fi |¤ŽS )a±  Creates a :class:`requests_oauthlib.OAuth2Session` instance from a
    Google-format client secrets file.

    Args:
        client_secrets_file (str): The path to the `client secrets`_ .json
            file.
        scopes (Sequence[str]): The list of scopes to request during the
            flow.
        kwargs: Any additional parameters passed to
            :class:`requests_oauthlib.OAuth2Session`

    Returns:
        Tuple[requests_oauthlib.OAuth2Session, Mapping[str, Any]]: The new
            oauthlib session and the validated client configuration.

    .. _client secrets:
        https://github.com/googleapis/google-api-python-client/blob/main/docs/client-secrets.md
    ÚrN)ÚopenÚjsonÚloadr   )Úclient_secrets_filer   r   Ú	json_filer   s        r   Ú session_from_client_secrets_filer!   K   s�   € õ& 
Ð! 3Ñ	'Ô	'ð -¨9Ýœ	 )Ñ,Ô,ˆð-ð -ð -ñ -ô -ð -ð -ð -ð -ð -ð -øøøð -ð -ð -ð -õ & m°VÐFÐF¸vÐFÐFÐFs   ‘2²6¹6c                 ó†  — |�|ni }| j         st          d¦  «        ‚d|v r�t          j        | j         d         | j                              d¦  «        |                     d¦  «        |                     d¦  «        |                     d¦  «        |                     d	¦  «        | j        ¬
¦  «        }n½t          j        j                             | j         d         | j                              d¦  «        | j                              d¦  «        |                     d¦  «        |                     d¦  «        |                     d¦  «        | j        | j                              d¦  «        ¬¦  «        }t          j	         
                    | j         d         t          j        j        ¦  «                             d¬¦  «        |_        |S )an  Creates :class:`google.oauth2.credentials.Credentials` from a
    :class:`requests_oauthlib.OAuth2Session`.

    :meth:`fetch_token` must be called on the session before before calling
    this. This uses the session's auth token and the provided client
    configuration to create :class:`google.oauth2.credentials.Credentials`.
    This allows you to use the credentials from the session with Google
    API client libraries.

    Args:
        session (requests_oauthlib.OAuth2Session): The OAuth 2.0 session.
        client_config (Mapping[str, Any]): The subset of the client
            configuration to use. For example, if you have a web client
            you would pass in `client_config['web']`.

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

    Raises:
        ValueError: If there is no access token in the session.
    NzDThere is no access token for this session, did you call fetch_token?Ú3piÚaccess_tokenÚrefresh_tokenr   r   Úclient_secretÚtoken_info_url)Útokenr%   Ú	token_urlr   r&   r'   r   Úid_tokenr
   )r%   r*   r   r   r&   r   Úgranted_scopesÚ
expires_at)Útzinfo)r(   r   r   ÚCredentialsÚgetr
   ÚgoogleÚoauth2ÚcredentialsÚdatetimeÚfromtimestampÚtimezoneÚutcÚreplaceÚexpiry)r   r   r2   s      r   Úcredentials_from_sessionr9   d   s£  € ð, &3Ð%>�M�MÀB€MàŒ=ð 
ÝØRñ
ô 
ð 	
ð �ÐÐÝ6ÔBØ”- Ô/Ø!œ-×+Ò+¨OÑ<Ô<Ø#×'Ò'¨Ñ4Ô4Ø#×'Ò'¨Ñ4Ô4Ø'×+Ò+¨OÑ<Ô<Ø(×,Ò,Ð-=Ñ>Ô>Ø”=ð
ñ 
ô 
ˆˆõ ”mÔ/×;Ò;ØŒM˜.Ô)Ø!œ-×+Ò+¨OÑ<Ô<Ø”]×&Ò& zÑ2Ô2Ø#×'Ò'¨Ñ4Ô4Ø#×'Ò'¨Ñ4Ô4Ø'×+Ò+¨OÑ<Ô<Ø”=Ø"œ=×,Ò,¨WÑ5Ô5ð <ñ 	
ô 	
ˆõ "Ô*×8Ò8ØŒ�lÔ#¥XÔ%6Ô%:ñô ç‚g�T€gÑÔð Ôð Ðr   )N)Ú__doc__r3   r   Úgoogle.oauth2.credentialsr0   r   Úgoogle.authr   Ú	frozensetr   r   r!   r9   r   r   r   ú<module>r>      sž   ððð ð €€€Ø €€€à  Ð  Ð  Ð  Ø Ð Ð Ð Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8à!˜	Ð"HÑIÔIÐ ð&"ð &"ð &"ðRGð Gð Gð25ð 5ð 5ð 5ð 5ð 5r   