
    Ki8                     ,   S r SSKrSSKrSSKJr  SSKJrJrJrJ	r	J
r
JrJrJr  SSKJr   SSKJr  S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J r   SS/r!SS/r"S\RF                  S:H  4S\$S\%S\4S jjr&\&" 5       r'\'S-  r(\'S-  r)\'S-  r*\S4S\S\ S\
\   S\4S jjr+ " S S\5      r, S4S \	\$\4   S!\\$   S"\-S\4S# jjr.\)4S$\S\
\   4S% jjr/\)S&4S'\S$\S(\$SS4S) jjr0\!\.\(\)\4S!\\$   S*\,S+\\$\4   S,\\$\4   S\ S\4S- jjr1SS\!\.\4S\
\	\$\4      S.\
\	\$\4      S!\\$   S*\,S\ S\\\\$\4   4   4S/ jjr2\*\!\4S$\\\$4   S!\\$   S\ S\4S0 jjr3\!\4S1\	\$\4   S!\\$   S\ S\4S2 jjr4\4S&\$S\ S\4S3 jjr5g! \ a    Sr GN^f = f)5z?
gspread.auth
~~~~~~~~~~~~

Simple authentication with OAuth.

    N)Path)AnyDictIterableMappingOptionalProtocolTupleUnion)CredentialsTF)InstalledAppFlow)Session   Client)
HTTPClientHTTPClientTypez,https://www.googleapis.com/auth/spreadsheetsz%https://www.googleapis.com/auth/drivez5https://www.googleapis.com/auth/spreadsheets.readonlyz.https://www.googleapis.com/auth/drive.readonlygspreadntconfig_dir_nameos_is_windowsreturnc                     U(       a  [        [        R                  S   U 5      $ [        [         R                  " 5       SU 5      $ )zzConstruct a config dir path.

By default:
    * `%APPDATA%\gspread` on Windows
    * `~/.config/gspread` everywhere else

APPDATAz.config)r   osenvironhome)r   r   s     _C:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\gspread/auth.pyget_config_dirr   )   s2     BJJy)?;;DIIKO<<    zcredentials.jsonzauthorized_user.jsonzservice_account.jsoncredentialshttp_clientsessionc                     [        XUS9$ )a4  Login to Google API using OAuth2 credentials.
This is a shortcut/helper function which
instantiates a client using `http_client`.
By default :class:`gspread.HTTPClient` is used (but could also use
:class:`gspread.BackOffHTTPClient` to avoid rate limiting).

It can take an additional `requests.Session` object in order to provide
you own session object.

.. note::

   When providing your own `requests.Session` object,
   use the value `None` as `credentials`.

:returns: An instance of the class produced by `http_client`.
:rtype: :class:`gspread.client.Client`
)authr#   r"   r   )r!   r"   r#   s      r   	authorizer&   @   s    . {MMr    c            	       H    \ rS rSrSr S
S\\\4   S\\   S\	S\
4S jjrSrg	)FlowCallableZ   z"Protocol for OAuth flow callables.client_configscopesportr   c                     g N )selfr*   r+   r,   s       r   __call__FlowCallable.__call__]   s    r    r/   Nr   )__name__
__module____qualname____firstlineno____doc__r   strr   r   intOAuthCredentialsr1   __static_attributes__r/   r    r   r(   r(   Z   sC    , TU$S#X.8@MP	 r    r(   r*   r+   r,   c                 L    [         R                  " X5      nUR                  US9$ )a  Run an OAuth flow using a local server strategy.

Creates an OAuth flow and runs `google_auth_oauthlib.flow.InstalledAppFlow.run_local_server <https://google-auth-oauthlib.readthedocs.io/en/latest/reference/google_auth_oauthlib.flow.html#google_auth_oauthlib.flow.InstalledAppFlow.run_local_server>`_.
This will start a local web server and open the authorization URL in
the user's browser.

Pass this function to ``flow`` parameter of :meth:`~gspread.oauth` to run
a local server flow.
)r,   )r   from_client_configrun_local_server)r*   r+   r,   flows       r   local_server_flowrA   b   s(     ..}ED  d ++r    filenamec                 Z    U R                  5       (       a  [        R                  " U 5      $ g r.   )existsr;   from_authorized_user_filerB   s    r   load_credentialsrG   r   s%     99(CCr    tokencredsstripc                     UR                   R                  SSS9  UR                  S5       nUR                  U R	                  U5      5        S S S 5        g ! , (       d  f       g = f)NT)parentsexist_okw)parentmkdiropenwriteto_json)rI   rB   rJ   fs       r   store_credentialsrU   {   sJ    
 OO$6	s	q	e$% 
		s   !A
A$r@   credentials_filenameauthorized_user_filenamec                     [        U5      n[        US9n[        U[        5      (       d:  [	        U5       n[
        R                  " U5      nSSS5        U" WU S9n[        XSS9  [        XTS9$ ! , (       d  f       N'= f)a	  Authenticate with OAuth Client ID.

By default this function will use the local server strategy and open
the authorization URL in the user's browser::

    gc = gspread.oauth()

Another option is to run a console strategy. This way, the user is
instructed to open the authorization URL in their browser. Once the
authorization is complete, the user must then copy & paste the
authorization code into the application::

    gc = gspread.oauth(flow=gspread.auth.console_flow)


``scopes`` parameter defaults to read/write scope available in
``gspread.auth.DEFAULT_SCOPES``. It's read/write for Sheets
and Drive API::

    DEFAULT_SCOPES =[
        'https://www.googleapis.com/auth/spreadsheets',
        'https://www.googleapis.com/auth/drive'
    ]

You can also use ``gspread.auth.READONLY_SCOPES`` for read only access.
Obviously any method of ``gspread`` that updates a spreadsheet
**will not work** in this case::

    gc = gspread.oauth(scopes=gspread.auth.READONLY_SCOPES)

    sh = gc.open("A spreadsheet")
    sh.sheet1.update_acell('A1', '42')   # <-- this will not work

If you're storing your user credentials in a place other than the
default, you may provide a path to that file like so::

    gc = gspread.oauth(
        credentials_filename='/alternative/path/credentials.json',
        authorized_user_filename='/alternative/path/authorized_user.json',
    )

:param list scopes: The scopes used to obtain authorization.
:param function flow: OAuth flow to use for authentication.
    Defaults to :meth:`~gspread.auth.local_server_flow`
:param str credentials_filename: Filepath (including name) pointing to a
    credentials `.json` file.
    Defaults to DEFAULT_CREDENTIALS_FILENAME:

        * `%APPDATA%\gspread\credentials.json` on Windows
        * `~/.config/gspread/credentials.json` everywhere else
:param str authorized_user_filename: Filepath (including name) pointing to
    an authorized user `.json` file.
    Defaults to DEFAULT_AUTHORIZED_USER_FILENAME:

        * `%APPDATA%\gspread\authorized_user.json` on Windows
        * `~/.config/gspread/authorized_user.json` everywhere else
:type http_client: :class:`gspread.http_client.HTTPClient`
:param http_client: A factory function that returns a client class.
    Defaults to :class:`gspread.http_client.HTTPClient` (but could also use
    :class:`gspread.http_client.BackOffHTTPClient` to avoid rate limiting)

:rtype: :class:`gspread.client.Client`
rF   Nr*   r+   r%   r"   )	r   rG   
isinstancer   rQ   jsonloadrU   r   )r+   r@   rV   rW   r"   rI   	json_filer*   s           r   oauthr_      so    N  $$<=&>?Ee[))&'9 IIi0M (=@%Cu66 ('s   A--
A;authorized_user_infoc                     Ub  [         R                  " X5      nOU b  U" XS9nO[        S5      e[        XTS9nXeR	                  S5      4$ )a  Authenticate with OAuth Client ID.

By default this function will use the local server strategy and open
the authorization URL in the user's browser::

    gc = gspread.oauth_from_dict()

Another option is to run a console strategy. This way, the user is
instructed to open the authorization URL in their browser. Once the
authorization is complete, the user must then copy & paste the
authorization code into the application::

    gc = gspread.oauth_from_dict(flow=gspread.auth.console_flow)


``scopes`` parameter defaults to read/write scope available in
``gspread.auth.DEFAULT_SCOPES``. It's read/write for Sheets
and Drive API::

    DEFAULT_SCOPES =[
        'https://www.googleapis.com/auth/spreadsheets',
        'https://www.googleapis.com/auth/drive'
    ]

You can also use ``gspread.auth.READONLY_SCOPES`` for read only access.
Obviously any method of ``gspread`` that updates a spreadsheet
**will not work** in this case::

    gc = gspread.oauth_from_dict(scopes=gspread.auth.READONLY_SCOPES)

    sh = gc.open("A spreadsheet")
    sh.sheet1.update_acell('A1', '42')   # <-- this will not work

This function requires you to pass the credentials directly as
a python dict. After the first authentication the function returns
the authenticated user info, this can be passed again to authenticate
the user without the need to run the flow again.

..
    code block below must be explicitly announced using code-block

.. code-block:: python

    gc = gspread.oauth_from_dict(
            credentials=my_creds,
            authorized_user_info=my_auth_user
    )

:param dict credentials: The credentials from google cloud platform
:param dict authorized_user_info: The authenticated user
    if already authenticated.
:param list scopes: The scopes used to obtain authorization.
:param function flow: OAuth flow to use for authentication.
    Defaults to :meth:`~gspread.auth.local_server_flow`
:type http_client: :class:`gspread.http_client.HTTPClient`
:param http_client: A factory function that returns a client class.
    Defaults to :class:`gspread.http_client.HTTPClient` (but could also use
    :class:`gspread.http_client.BackOffHTTPClient` to avoid rate limiting)

:rtype: (:class:`gspread.client.Client`, str)
rY   zno credentials object suppliedrZ   rH   )r;   from_authorized_user_info
ValueErrorr   rS   )r!   r`   r+   r@   r"   rI   clients          r   oauth_from_dictre      sV    J ' ::;OX		 ;>9::8F
 MM'*++r    c                 <    [         R                  " XS9n[        X2S9$ )a  Authenticate using a service account.

``scopes`` parameter defaults to read/write scope available in
``gspread.auth.DEFAULT_SCOPES``. It's read/write for Sheets
and Drive API::

    DEFAULT_SCOPES =[
        'https://www.googleapis.com/auth/spreadsheets',
        'https://www.googleapis.com/auth/drive'
    ]

You can also use ``gspread.auth.READONLY_SCOPES`` for read only access.
Obviously any method of ``gspread`` that updates a spreadsheet
**will not work** in this case.

:param str filename: The path to the service account json file.
:param list scopes: The scopes used to obtain authorization.
:type http_client: :class:`gspread.http_client.HTTPClient`
:param http_client: A factory function that returns a client class.
    Defaults to :class:`gspread.HTTPClient` (but could also use
    :class:`gspread.BackOffHTTPClient` to avoid rate limiting)

:rtype: :class:`gspread.client.Client`
)r+   rZ   )SACredentialsfrom_service_account_filer   )rB   r+   r"   rI   s       r   service_accountri   ,  s    : 33HLEu66r    infoc                 >    [         R                  " U US9n[        X2S9$ )a  Authenticate using a service account (json).

``scopes`` parameter defaults to read/write scope available in
``gspread.auth.DEFAULT_SCOPES``. It's read/write for Sheets
and Drive API::

    DEFAULT_SCOPES =[
        'https://www.googleapis.com/auth/spreadsheets',
        'https://www.googleapis.com/auth/drive'
    ]

You can also use ``gspread.auth.READONLY_SCOPES`` for read only access.
Obviously any method of ``gspread`` that updates a spreadsheet
**will not work** in this case.

:param info (Mapping[str, str]): The service account info in Google format
:param list scopes: The scopes used to obtain authorization.
:type http_client: :class:`gspread.http_client.HTTPClient`
:param http_client: A factory function that returns a client class.
    Defaults to :class:`gspread.http_client.HTTPClient` (but could also use
    :class:`gspread.http_client.BackOffHTTPClient` to avoid rate limiting)

:rtype: :class:`gspread.client.Client`
)rj   r+   rZ   )rg   from_service_account_infor   )rj   r+   r"   rI   s       r   service_account_from_dictrm   M  s'    : 33E u66r    c                 R    [         SL a  [        S5      e[        U 5      n[        X!S9$ )a<  Authenticate using an API key.

Allows you to open public spreadsheet files.

.. warning::

   This method only allows you to open public spreadsheet files.
   It does not work for private spreadsheet files.

:param token str: The actual API key to use
:type http_client: :class:`gspread.http_client.HTTPClient`
:param http_client: A factory function that returns a client class.
    Defaults to :class:`gspread.http_client.HTTPClient` (but could also use
    :class:`gspread.http_client.BackOffHTTPClient` to avoid rate limiting)

:rtype: :class:`gspread.client.Client`

Fznapi_key is only available with package google.auth>=2.15.0. Install it with "pip install google-auth>=2.15.0".rZ   )GOOGLE_AUTH_API_KEY_AVAILABLENotImplementedErrorAPIKeyCredentialsr   )rH   r"   rI   s      r   api_keyrr   q  s6    & %-!A
 	
 e$Eu66r    r3   )6r8   r\   r   pathlibr   typingr   r   r   r   r   r	   r
   r   google.auth.credentialsr   google.auth.api_keyrq   ro   ImportErrorgoogle.oauth2.credentialsr;   google.oauth2.service_accountrg   google_auth_oauthlib.flowr   requestsr   rd   r   r"   r   r   DEFAULT_SCOPESREADONLY_SCOPESnamer9   boolr   DEFAULT_CONFIG_DIRDEFAULT_CREDENTIALS_FILENAME DEFAULT_AUTHORIZED_USER_FILENAME DEFAULT_SERVICE_ACCOUNT_FILENAMEr&   r(   r:   rA   rG   rU   r_   re   ri   rm   rr   r/   r    r   <module>r      s;    	  Q Q Q /*D$(! F F 6   3 3+ <4 %BGGtO==59=	=  $% 14FF #58N#N  #58N#N  
 #-!%NNN gN 	N48  JK,38$,.6sm,CF,," 6k 6&&& & 
	& +*-I1Q",P7SMP7
P7  T	*P7 $CI.	P7
  P7 P7h 048<**",Q,'#s(+,Q,"738#45Q, SMQ, 	Q,
  Q, 64S>!"Q,j "B*",7D#I7SM7  7 	7F +",!7
#s(
!7SM!7  !7 	!7H 7A 73 7^ 7V 7{
  *$)!*s   F FF