
    5pj                        S r SSKJr  SSKrSSKJr  SSKJr  SSKJ	r	J
r
JrJrJr  SSKJr  SS	KJrJrJrJr  SS
KJrJr  SSKJrJr  SSKJr  SSKJrJr  \R@                  " \!5      r"\" SS9r#\#RI                  S/ SQS9   S1S\S\\%\" SS94   S\\%\" SS94   SS4S jj5       r&\#RI                  SSS/S9 S2S\\'S-  \" SS94   SS4S  jj5       r(S\'S-  4S! jr)\#RI                  S"S#S$/S9  S3S\\'S-  \" S%S94   S\\%\" SS94   SS4S& jj5       r*\#RI                  S'S(/S9S4S) j5       r+\#RI                  SS*S+/S9S4S, j5       r,\#RI                  S-S.S//S9S4S0 j5       r-g)5z^Contains commands to authenticate to the Hugging Face Hub and interact with your repositories.    )	AnnotatedN)ENDPOINT)whoami   )_save_oauth_token	auth_listauth_switchloginlogout)CLIError)get_stored_tokens	get_tokenloggingselect_choice)poll_device_tokenrequest_device_code   )TokenOpttyper_factory)Option)OutputFormatoutz,Manage authentication (login, logout, etc.).)helpr
   )zhf auth loginzhf auth login --token $HF_TOKENz7hf auth login --token $HF_TOKEN --add-to-git-credentialzhf auth login --force)examplestokenadd_to_git_credentialzTSave to git credential helper. Useful only if you plan to run git commands directly.forcez)Force re-login even if already logged in.returnc           	         U c"  [         R                  [        R                  :X  a  [	        XU(       + S9  g[         R                  [        R
                  :w  a  [        S5      eU(       d   [        5       b  [         R                  " SS9  g[        5       n[         R                  " SUS    SUS	    S
US    S3S9  [        U5      n[        U5      u  pV[         R                  " SU SU S3S9  g)zNLogin from your browser, or using a token from huggingface.co/settings/tokens.N)r   r   skip_if_logged_inzr`hf auth login` is interactive and does not support --format json/quiet. Pass --token for a non-interactive login.z;Already logged in. Use `hf auth login --force` to re-login.)agentzAsk the user to open verification_uri_completez! in a browser and enter the code 	user_codez. The code expires in 
expires_inz& seconds. Waiting for authorization...zLogin successful: logged in as z (token saved as 'z').)r   moder   humanr
   r!   r   r   textr   r   r   )r   r   r   device_inforesponse
token_nameusernames          T/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/huggingface_hub/cli/auth.py
auth_loginr-   &   s    2 CHH(:(::E^cZcd xx<%%%8
 	
 Y[,TU%'KHH#K0K$L#MMn;'((>{<?X>Y Z++ !-H,X6JHH4XJ>PQ[P\\_`a    r   zhf auth logoutz$hf auth logout --token-name my-tokenr*   zName of token to logoutc                     [        U S9  g)zLogout from a specific token.r*   N)r   r0   s    r,   auth_logoutr1   \   s     j!r.   c                      [        [        5       R                  5       5      n U (       d  [        R	                  S5        g [
        R                  [        R                  :w  a  [        S5      eU [        SU 5         $ )Nz+No stored tokens found. Please login first.z;Use --token-name to select a token in non-interactive mode.zSelect a token to switch to:)listr   keysloggererrorr   r%   r   r&   r   r   )token_namess    r,   _select_token_namer8   j   s]    (*//12KBC
xx<%%%TUU}%C[QRRr.   switchzhf auth switchz$hf auth switch --token-name my-tokenzName of the token to switch toc                     U c
  [        5       n U c)  [        S5        [        R                  R	                  5       e[        XS9  g)zSwitch between access tokens.Nz!No token name provided. Aborting.)r   )r8   printclick
exceptionsExitr	   )r*   r   s     r,   auth_switch_cmdr?   v   s>    & ')
12##%%
Hr.   z	list | lszhf auth listc                      [        5         g)zList all stored access tokens.N)r    r.   r,   auth_list_cmdrB      s	     Kr.   zhf auth tokenz8hf auth token | xargs curl -H 'Authorization: Bearer {}'c                      [        5       n U c3  [        R                  " S5        [        R                  R                  SS9e[        U 5        [        R                  " S5        g)z)Print the current access token to stdout.Nz)Not logged in. Run `hf auth login` first.r   codez@Run `hf auth whoami` to see which account this token belongs to.)r   r   r6   r<   r=   r>   r;   hint)r   s    r,   
auth_tokenrG      sK     KE}		=>###++	%LHHOPr.   r   zhf auth whoamizhf auth whoami --format jsonc                  8   [        5       n U c3  [        R                  " S5        [        R                  R                  SS9e[        U 5      nSR                  S US    5       5      =(       d    Sn[        S:w  a  [        OSn[        R                  " S	US
   X#S9  g)z;Find out which huggingface.co account you are logged in as.NzNot logged inr   rD   ,c              3   *   #    U  H	  oS    v   M     g7f)nameNrA   ).0orgs     r,   	<genexpr>auth_whoami.<locals>.<genexpr>   s     8<CK<s   orgszhttps://huggingface.coz	Logged inrK   )userrP   endpoint)
r   r   r6   r<   r=   r>   r   joinr   result)r   inforP   rR   s       r,   auth_whoamirV      s     KE}		/"###++%=D8884<88@DD#'??xTHJJ{fDLr.   )NFF)N)NF)r   N).__doc__typingr   r<   huggingface_hub.constantsr   huggingface_hub.hf_apir   _loginr   r   r	   r
   r   errorsr   utilsr   r   r   r   utils._oauth_devicer   r   
_cli_utilsr   r   
_frameworkr   _outputr   r   
get_logger__name__r5   auth_clicommandboolr-   strr1   r8   r?   rB   rG   rV   rA   r.   r,   <module>rh      sk   e   . ) M M  H H H /  & 
		H	% LM 
    	 	*b*b$g	
	*b <	
	*b 
*b*bZ 
 FG   		"d
-.	0"
 
"	"	SC$J 	S 
 FG   	 	Id
1	
	I %g	
	I 
I	I. 
+(89 :
 
'_6p$qrQ sQ 
(&68V%WXM YMr.   