
    g\                     |    d Z ddlZddl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dZd Zd Zd Zd ZddZy)z9Helpers for reading the Google Cloud SDK's configuration.    N)_helpers)environment_vars)
exceptionsgcloudAPPDATAz$application_default_credentials.jsonz
gcloud.cmd)configgetproject)authzprint-access-tokenzH764086051850-6qr4p6gpi6hn506pt8ejuq83di341hur.apps.googleusercontent.comc                  *   	 t         j                  t        j                     S # t        $ r Y nw xY wt         j
                  dk7  rBt         j                  j                  t         j                  j                  d      dt              S 	 t         j                  j                  t         j                  t           t              S # t        $ rH t         j                  j                  dd      } t         j                  j                  | dt              cY S w xY w)zReturns the absolute path the the Cloud SDK's configuration directory.

    Returns:
        str: The Cloud SDK config path.
    nt~z.configSystemDrivezC:\)osenvironr   CLOUD_SDK_CONFIG_DIRKeyErrornamepathjoin
expanduser_CONFIG_DIRECTORY_WINDOWS_CONFIG_ROOT_ENV_VARr	   )drives    K/var/www/openai/venv/lib/python3.12/site-packages/google/auth/_cloud_sdk.pyget_config_pathr   -   s    zz*??@@  
ww$ww||BGG..s3Y@QRR	@77<<

78:K   	@ JJNN=$7E77<<t->??		@s    # 	//8C ADDc                  ^    t               } t        j                  j                  | t              S )zGets the path to the application default credentials file.

    The path may or may not exist.

    Returns:
        str: The full path to application default credentials.
    )r   r   r   r   _CREDENTIALS_FILENAME)config_paths    r   (get_application_default_credentials_pathr!   I   s"     "#K77<<%:;;    c                     t        t        j                  d      5 }t        j                  | |      }ddd       |S # 1 sw Y   S xY w)zJ Return subprocess.check_output with the given command and ignores stderr.wstderrN)openr   devnull
subprocesscheck_output)commandr(   outputs      r   _run_subprocess_ignore_stderrr-   U   s9    	bjj#	'((A 
M 
Ms	   =Ac                     t         j                  dk(  rt        } nt        } 	 t	        | ft
        z         }t        j                  |      j                         }|r|S dS # t        j                  t        t        f$ r Y yw xY w)zaGets the project ID from the Cloud SDK.

    Returns:
        Optional[str]: The project ID.
    r   N)r   r   _CLOUD_SDK_WINDOWS_COMMAND_CLOUD_SDK_POSIX_COMMANDr-   %_CLOUD_SDK_CONFIG_GET_PROJECT_COMMANDr   
from_bytesstripr)   CalledProcessErrorOSErrorIOError)r+   r
   s     r   get_project_idr7   \   s|     
ww$,* 0J>>

 %%g.446!w+t+))7G< s   9A A A?>A?c                    t         j                  dk(  rt        }nt        }	 | r|ft        z   d| z   fz   }n
|ft        z   }t        j                  |t
        j                        }|j                  d      j                         S # t
        j                  t        t        f$ r}t        j                  d|      }||d}~ww xY w)a  Load user access token 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.

    Returns:
        str: The user access token.

    Raises:
        google.auth.exceptions.UserAccessTokenError: if failed to get access
            token from gcloud.
    r   z
--account=r%   zutf-8zFailed to obtain access tokenN)r   r   r/   r0   $_CLOUD_SDK_USER_ACCESS_TOKEN_COMMANDr)   r*   STDOUTdecoder3   r4   r5   r6   r   UserAccessTokenError)accountr+   access_token
caught_excnew_excs        r   get_auth_access_tokenrA   u   s     
ww$,*&
67')+,  j#GGG!..wz?P?PQ""7+1133))7G< &11+Z
 :%	&s   A!B C "B;;C )N)__doc__r   r)   google.authr   r   r   r   r   r   r0   r/   r1   r9   CLOUD_SDK_CLIENT_IDr   r!   r-   r7   rA    r"   r   <module>rF      sm    @ 	    ( "  (  ? # ) (D %'E $ O 
@8	<2$&r"   