
    (ph                         S 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
  \R                  " 5       r/ SQr\R                  " SSS	/5      r  " S
 S5      r " S S\5      r " S S\5      r " S S\5      rS rg)zFirebase credentials module.    N)requests)credentials)service_account)z.https://www.googleapis.com/auth/cloud-platformz)https://www.googleapis.com/auth/datastorez5https://www.googleapis.com/auth/devstorage.read_writez(https://www.googleapis.com/auth/firebasez/https://www.googleapis.com/auth/identitytoolkitz.https://www.googleapis.com/auth/userinfo.emailAccessTokenInfoaccess_tokenexpiryc                   $    \ rS rSrSrS rS rSrg)Base,   z>Provides OAuth2 access tokens for accessing Firebase services.c                     U R                  5       nUR                  [        5        [        UR                  UR
                  5      $ )zFetches a Google OAuth2 access token using this credential instance.

Returns:
  AccessTokenInfo: An access token obtained using the credential.
)get_credentialrefresh_requestr   tokenr   )selfgoogle_creds     M/var/www/html/venv/lib/python3.13/site-packages/firebase_admin/credentials.pyget_access_tokenBase.get_access_token/   s9     ))+H%{00+2D2DEE    c                     [         e)z?Returns the Google credential instance used for authentication.)NotImplementedErrorr   s    r   r   Base.get_credential9   s    !!r    N)__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes__r   r   r   r
   r
   ,   s    HF"r   r
   c                   f   ^  \ rS rSrSrSrU 4S jr\S 5       r\S 5       r	\S 5       r
S rS	rU =r$ )
Certificate>   z9A credential initialized from a JSON certificate keyfile.r   c                 T  > [         [        U ]  5         [        U5      (       a+  [	        U5       n[
        R                  " U5      nSSS5        O2[        U[        5      (       a  UnO[        SR                  U5      5      eWR                  S5      U R                  :w  a$  [        SR                  U R                  5      5      e [        R                  R                  U[         S9U l        g! , (       d  f       Nz= f! [         a  n[        SR                  U5      5      eSnAff = f)a  Initializes a credential from a Google service account certificate.

Service account certificates can be downloaded as JSON files from the Firebase console.
To instantiate a credential from a certificate file, either specify the file path or a
dict representing the parsed contents of the file.

Args:
  cert: Path to a certificate file or a dict representing the contents of a certificate.

Raises:
  IOError: If the specified certificate file doesn't exist or cannot be read.
  ValueError: If the specified certificate is invalid.
Nz}Invalid certificate argument: "{0}". Certificate argument must be a file path, or a dict containing the parsed file contents.typezZInvalid service account certificate. Certificate must contain a "type" field set to "{0}".scopesz?Failed to initialize a certificate credential. Caused by: "{0}")superr#   __init___is_file_pathopenjsonload
isinstancedict
ValueErrorformatget_CREDENTIAL_TYPEr   Credentialsfrom_service_account_info_scopes_g_credential)r   cert	json_file	json_dataerror	__class__s        r   r*   Certificate.__init__C   s    	k4)+dy IIi0	 d##IAAGO O == D$9$99 ::@&AVAV:WY Y	?!0!<!<!V!V' "W "+D   	? 006u? ?	?s#   C-'C> -
C;>
D'D""D'c                 .    U R                   R                  $ N)r8   
project_idr   s    r   rA   Certificate.project_idf   s    !!,,,r   c                 .    U R                   R                  $ r@   )r8   signerr   s    r   rD   Certificate.signerj   s    !!(((r   c                 .    U R                   R                  $ r@   )r8   service_account_emailr   s    r   rG   !Certificate.service_account_emailn   s    !!777r   c                     U R                   $ z}Returns the underlying Google credential.

Returns:
  google.auth.credentials.Credentials: A Google Auth credential instance.r8   r   s    r   r   Certificate.get_credentialr       
 !!!r   rK   )r   r   r   r   r    r4   r*   propertyrA   rD   rG   r   r!   __classcell__r=   s   @r   r#   r#   >   sX    C(!?F - - ) ) 8 8" "r   r#   c                   H   ^  \ rS rSrSrU 4S jrS r\S 5       rS r	Sr
U =r$ )ApplicationDefaultz   z(A Google Application Default credential.c                 8   > [         [        U ]  5         SU l        g)zCreates an instance that will use Application Default credentials.

The credentials will be lazily initialized when get_credential() or
project_id() is called. See those methods for possible errors raised.
N)r)   rR   r*   r8   )r   r=   s    r   r*   ApplicationDefault.__init__}   s     	 $02!r   c                 :    U R                  5         U R                  $ )a  Returns the underlying Google credential.

Raises:
  google.auth.exceptions.DefaultCredentialsError: If Application Default
      credentials cannot be initialized in the current environment.
Returns:
  google.auth.credentials.Credentials: A Google Auth credential instance.)_load_credentialr8   r   s    r   r   !ApplicationDefault.get_credential   s     	!!!r   c                 :    U R                  5         U R                  $ )zReturns the project_id from the underlying Google credential.

Raises:
  google.auth.exceptions.DefaultCredentialsError: If Application Default
      credentials cannot be initialized in the current environment.
Returns:
  str: The project id.)rW   _project_idr   s    r   rA   ApplicationDefault.project_id   s     	r   c                     U R                   (       d/  [        R                  R                  [        S9u  U l         U l        g g )Nr'   )r8   googleauthdefaultr7   rZ   r   s    r   rW   #ApplicationDefault._load_credential   s2    !!39;;3F3Fg3F3V0D 0 "r   )r8   rZ   )r   r   r   r   r    r*   r   rN   rA   rW   r!   rO   rP   s   @r   rR   rR   z   s0    2"	" 	  	 W Wr   rR   c                   f   ^  \ rS rSrSrSrU 4S jr\S 5       r\S 5       r	\S 5       r
S rS	rU =r$ )
RefreshToken   z8A credential initialized from an existing refresh token.authorized_userc                   > [         [        U ]  5         [        U5      (       a+  [	        U5       n[
        R                  " U5      nSSS5        O2[        U[        5      (       a  UnO[        SR                  U5      5      eWR                  S5      U R                  :w  a$  [        SR                  U R                  5      5      e[        R                  R                  U[         5      U l        g! , (       d  f       N{= f)a[  Initializes a credential from a refresh token JSON file.

The JSON must consist of client_id, client_secret and refresh_token fields. Refresh
token files are typically created and managed by the gcloud SDK. To instantiate
a credential from a refresh token file, either specify the file path or a dict
representing the parsed contents of the file.

Args:
  refresh_token: Path to a refresh token file or a dict representing the contents of a
      refresh token file.

Raises:
  IOError: If the specified file doesn't exist or cannot be read.
  ValueError: If the refresh token configuration is invalid.
NzInvalid refresh token argument: "{0}". Refresh token argument must be a file path, or a dict containing the parsed file contents.r&   zSInvalid refresh token configuration. JSON must contain a "type" field set to "{0}".)r)   rb   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r   r5   from_authorized_user_infor7   r8   )r   refresh_tokenr:   r;   r=   s       r   r*   RefreshToken.__init__   s      	lD*,''m$	 IIi0	 %$t,,%IGGMvmG\^ ^ == D$9$99 ::@&AVAV:WY Y(44NNyZab %$s   C..
C<c                 .    U R                   R                  $ r@   )r8   	client_idr   s    r   rj   RefreshToken.client_id   s    !!+++r   c                 .    U R                   R                  $ r@   )r8   client_secretr   s    r   rm   RefreshToken.client_secret       !!///r   c                 .    U R                   R                  $ r@   )r8   rg   r   s    r   rg   RefreshToken.refresh_token   ro   r   c                     U R                   $ rJ   rK   r   s    r   r   RefreshToken.get_credential   rM   r   rK   )r   r   r   r   r    r4   r*   rN   rj   rm   rg   r   r!   rO   rP   s   @r   rb   rb      sY    B(c@ , , 0 0 0 0" "r   rb   c                 R     [         R                  " U 5        g! [         a     gf = f)NTF)pathlibPath	TypeError)paths    r   r+   r+      s(    T s    
&&)r    collectionsr-   ru   google.authr]   google.auth.transportr   google.oauth2r   r   Requestr   r7   
namedtupler   r
   r#   rR   rb   r+   r   r   r   <module>r      s    #     * % )  (():^X<VW" "$9"$ 9"x%W %WN6"4 6"rr   