Ë
    -Œ:jù  ã                   óX  — d Z ddlmZ ddlZddlmZ ddlmZ ddlm	Z	m
Z
mZmZmZ ddlmZ dd	lmZmZmZmZ dd
lmZmZ ddlmZmZ ddlmZmZ  ej<                  e«      Z  ed¬«      Z!e!jE                  dg d¢¬«      	 	 	 d0dedee# ejH                  d¬«      f   dee# ejH                  d¬«      f   ddfd„«       Z%e!jE                  dddg¬«      	 d1dee&dz   ejH                  d¬«      f   ddfd„«       Z'de&dz  fd „Z(e!jE                  d!d"d#g¬«      	 	 d2dee&dz   ejH                  d$¬«      f   dee# ejH                  d¬«      f   ddfd%„«       Z)e!jE                  d&d'g¬«      d3d(„«       Z*e!jE                  dd)d*g¬«      d3d+„«       Z+e!jE                  d,d-d.g¬«      d3d/„«       Z,y)4aÑ  Contains commands to authenticate to the Hugging Face Hub and interact with your repositories.

Usage:
    # login with a browser (OAuth device flow)
    hf auth login

    # login with an explicit token
    hf auth login --token=hf_*** --add-to-git-credential

    # switch between tokens
    hf auth switch

    # list all tokens
    hf auth list

    # logout from all tokens
    hf auth logout

    # check which account you are logged in as
    hf auth whoami
é    )Ú	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)Ú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           	      óÚ  — | €!t         j                  t        j                  k(  rt	        | || ¬«       yt         j                  t        j
                  k7  rt        d«      ‚|s!t        «       �t        j                  d¬«       yt        «       }t        j                  d|d   › d|d	   › d
|d   › d�¬«       t        |«      }t        |«      \  }}t        j                  d|› d|› d�¬«       y)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          úZ/var/www/html/tokenscope/api/venv/lib/python3.12/site-packages/huggingface_hub/cli/auth.pyÚ
auth_loginr,   9   sô   € ð2 ÐœCŸH™H¬×(:Ñ(:Ò:ä�EÐ1FÐ^cÐZcÕdØô ‡x�x”<×%Ñ%Ò%Üð8ó
ð 	
ñ ”Y“[Ð,Ü�‰ÐTÕUØÜ%Ó'€KÜ‡H�Hà# KÐ0KÑ$LÐ#MÐMnØ˜;Ñ'Ð(Ð(>¸{È<Ñ?XÐ>Yð Z+ð+õô ! Ó-€HÜ,¨XÓ6Ñ€J�Ü‡H�HÐ4°X°JÐ>PÐQ[ÐP\Ð\_Ð`Öaó    r   zhf auth logoutz$hf auth logout --token-name my-tokenr)   zName of token to logoutc                 ó   — t        | ¬«       y)zLogout from a specific token.©r)   N)r   r/   s    r+   Úauth_logoutr0   o   s   € ô �jÖ!r-   c                  óê   — t        t        «       j                  «       «      } | st        j	                  d«       y t
        j                  t        j                  k7  rt        d«      ‚| t        d| «         S )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_namer7   }   s]   € ÜÔ(Ó*×/Ñ/Ó1Ó2€KáÜ�‰ÐBÔCØä
‡x�x”<×%Ñ%Ò%ÜÐ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                 óx   — | €
t        «       } | €t        d«       t        j                  «       ‚t	        | |¬«       y)zSwitch between access tokens.Nz!No token name provided. Aborting.)r   )r7   ÚprintÚtyperÚExitr	   )r)   r   s     r+   Úauth_switch_cmdr=   ‰   s8   € ð& ÐÜ'Ó)ˆ
ØÐÜÐ1Ô2Ü�j‰j‹lÐÜ�
Ð2GÖHr-   z	list | lszhf auth listc                  ó   — t        «        y)zList all stored access tokens.N)r   © r-   r+   Úauth_list_cmdr@   ¤   s	   € ô …Kr-   zhf auth tokenz8hf auth token | xargs curl -H 'Authorization: Bearer {}'c                  ó²   — t        «       } | €+t        j                  d«       t        j                  d¬«      ‚t        | «       t        j                  d«       y)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   r5   r;   r<   r:   Úhint)r   s    r+   Ú
auth_tokenrE   ª   s@   € ô ‹K€EØ€}Ü�	‰	Ð=Ô>Ü�j‰j˜aÔ Ð Ü	ˆ%„LÜ‡H�HÐOÕPr-   r   zhf auth whoamizhf auth whoami --format jsonc                  ó   — t        «       } | €+t        j                  d«       t        j                  d¬«      ‚t        | «      }dj                  d„ |d   D «       «      xs d}t        dk7  rt        nd}t        j                  d	|d
   ||¬«       y)z;Find out which huggingface.co account you are logged in as.NzNot logged inr   rB   ú,c              3   ó&   K  — | ]	  }|d    –— Œ y­w)ÚnameNr?   )Ú.0Úorgs     r+   ú	<genexpr>zauth_whoami.<locals>.<genexpr>¿   s   è ø€ Ò8 C�C˜•KÑ8ùs   ‚Úorgszhttps://huggingface.coz	Logged inrI   )ÚuserrM   Úendpoint)	r   r   r5   r;   r<   r   Újoinr   Úresult)r   ÚinforM   rO   s       r+   Úauth_whoamirS   µ   sv   € ô ‹K€EØ€}Ü�	‰	�/Ô"Ü�j‰j˜aÔ Ð ä�%‹=€DØ�8‰8Ñ8¨4°©<Ô8Ó8Ò@¸D€DÜ#Ð'?Ò?�xÀT€HÜ‡J�Jˆ{  f¡°DÀ8Ö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   Ú_outputr   r   Ú
get_loggerÚ__name__r4   Úauth_cliÚcommandÚboolÚOptionr,   Ústrr0   r7   r=   r@   rE   rS   r?   r-   r+   ú<module>re      s‰  ðñõ, ã å .Ý )ç MÕ MÝ ß HÓ Hß Hß /ß &ð 
ˆ×	Ñ	˜HÓ	%€ñ ÐLÔM€ð 
×ÑØòð ó ð ð 	ð 	ñ*bØð*bà$ØØˆ�‰Øgô	
ð	ñð*bð ØØˆ�‰Ø<ô	
ð	ñð*bð 
ò*bóð*bðZ 
×ÑØØÐ FÐGð ó ð 	ñ	"ØØˆd‰
Øˆ�‰Ð3Ô4ð	6ñð"ð
 
ò"ó	ð"ð	S˜C $™Jó 	Sð 
×ÑØØÐ FÐGð ó ð 	ð 	ñIØØˆd‰
Øˆ�‰Ø1ô	
ð	ñðIð %ØØˆ�‰Øgô	
ð	ñðIð 
òIó	ðIð. 
×Ñ�+¨Ð(8ÐÓ9òó :ðð
 
×Ñ�' _Ð6pÐ$qÐÓròQó sðQð 
×Ñ�(Ð&6Ð8VÐ%WÐÓXòMó YñMr-   