import{s as ct,o as ut,n as lt}from"../chunks/scheduler.6062bdaf.js";import{S as ht,i as dt,g as s,s as o,r as d,A as ft,h as g,f as n,c as i,j as P,u as f,x as h,k as M,y as r,a,v as p,d as m,t as _,w as b}from"../chunks/index.4bca734e.js";import{T as gt}from"../chunks/Tip.b9ac1f03.js";import{D as ue}from"../chunks/Docstring.81ba5e3c.js";import{H as K,E as pt}from"../chunks/EditOnGithub.74ab2baa.js";function mt(Q){let l,T=`<a href="/docs/huggingface_hub/main/en/package_reference/authentication#huggingface_hub.login">login()</a> is a drop-in replacement method for <a href="/docs/huggingface_hub/main/en/package_reference/authentication#huggingface_hub.notebook_login">notebook_login()</a> as it wraps and
extends its capabilities.`;return{c(){l=s("p"),l.innerHTML=T},l(c){l=g(c,"P",{"data-svelte-h":!0}),h(l)!=="svelte-1nj8mkw"&&(l.innerHTML=T)},m(c,I){a(c,l,I)},p:lt,d(c){c&&n(l)}}}function _t(Q){let l,T=`When the token is not passed, <a href="/docs/huggingface_hub/main/en/package_reference/authentication#huggingface_hub.login">login()</a> will automatically detect if the script runs
in a notebook or not. However, this detection might not be accurate due to the
variety of notebooks that exists nowadays. If that is the case, you can always force
the UI by using <a href="/docs/huggingface_hub/main/en/package_reference/authentication#huggingface_hub.notebook_login">notebook_login()</a> or <a href="/docs/huggingface_hub/main/en/package_reference/authentication#huggingface_hub.interpreter_login">interpreter_login()</a>.`;return{c(){l=s("p"),l.innerHTML=T},l(c){l=g(c,"P",{"data-svelte-h":!0}),h(l)!=="svelte-8dfgxw"&&(l.innerHTML=T)},m(c,I){a(c,l,I)},p:lt,d(c){c&&n(l)}}}function bt(Q){let l,T,c,I,D,de,V,Be="The <code>huggingface_hub</code> library allows users to programmatically manage authentication to the Hub. This includes logging in, logging out, switching between tokens, and listing available tokens.",fe,F,Je='For more details about authentication, check out <a href="../quick-start#authentication">this section</a>.',pe,q,me,u,z,Me,X,Ke="Login the machine to access the Hub.",De,Y,Qe=`The <code>token</code> is persisted in cache and set as a git credential. Once done, the machine
is logged in and the access token will be available across all <code>huggingface_hub</code>
components. If <code>token</code> is not provided, it will be prompted to the user either with
a widget (in a notebook) or via the terminal.`,Ve,Z,Xe=`To log in from outside of a script, one can also use <code>huggingface-cli login</code> which is
a cli command that wraps <a href="/docs/huggingface_hub/main/en/package_reference/authentication#huggingface_hub.login">login()</a>.`,Fe,L,qe,H,_e,N,be,w,j,ze,ee,Ye="Displays a prompt to log in to the HF website and store the token.",Ne,te,Ze=`This is equivalent to <a href="/docs/huggingface_hub/main/en/package_reference/authentication#huggingface_hub.login">login()</a> without passing a token when not run in a notebook.
<a href="/docs/huggingface_hub/main/en/package_reference/authentication#huggingface_hub.interpreter_login">interpreter_login()</a> is useful if you want to force the use of the terminal prompt
instead of a notebook widget.`,je,ne,et='For more details, see <a href="/docs/huggingface_hub/main/en/package_reference/authentication#huggingface_hub.login">login()</a>.',$e,O,we,v,A,Oe,oe,tt="Displays a widget to log in to the HF website and store the token.",Ae,ie,nt=`This is equivalent to <a href="/docs/huggingface_hub/main/en/package_reference/authentication#huggingface_hub.login">login()</a> without passing a token when run in a notebook.
<a href="/docs/huggingface_hub/main/en/package_reference/authentication#huggingface_hub.notebook_login">notebook_login()</a> is useful if you want to force the use of the notebook widget
instead of a prompt in the terminal.`,Se,ae,ot='For more details, see <a href="/docs/huggingface_hub/main/en/package_reference/authentication#huggingface_hub.login">login()</a>.',ve,S,ke,k,U,Ue,re,it="Logout the machine from the Hub.",Ge,se,at="Token is deleted from the machine and removed from git credential.",xe,G,Te,y,R,Re,ge,rt="Switch to a different access token.",ye,W,Ce,C,B,We,le,st="List all stored access tokens.",Ie,J,Le,he,He;return D=new K({props:{title:"Authentication",local:"authentication",headingTag:"h1"}}),q=new K({props:{title:"login",local:"huggingface_hub.login",headingTag:"h2"}}),z=new ue({props:{name:"huggingface_hub.login",anchor:"huggingface_hub.login",parameters:[{name:"token",val:": typing.Optional[str] = None"},{name:"add_to_git_credential",val:": bool = False"},{name:"new_session",val:": bool = True"},{name:"write_permission",val:": bool = False"}],parametersDescription:[{anchor:"huggingface_hub.login.token",description:`<strong>token</strong> (<code>str</code>, <em>optional</em>) &#x2014;
User access token to generate from <a href="https://huggingface.co/settings/token" rel="nofollow">https://huggingface.co/settings/token</a>.`,name:"token"},{anchor:"huggingface_hub.login.add_to_git_credential",description:`<strong>add_to_git_credential</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
If <code>True</code>, token will be set as git credential. If no git credential helper
is configured, a warning will be displayed to the user. If <code>token</code> is <code>None</code>,
the value of <code>add_to_git_credential</code> is ignored and will be prompted again
to the end user.`,name:"add_to_git_credential"},{anchor:"huggingface_hub.login.new_session",description:`<strong>new_session</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
If <code>True</code>, will request a token even if one is already saved on the machine.`,name:"new_session"},{anchor:"huggingface_hub.login.write_permission",description:`<strong>write_permission</strong> (<code>bool</code>) &#x2014;
Ignored and deprecated argument.`,name:"write_permission"}],source:"https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/_login.py#L58",raiseDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<ul>
<li><a
  href="https://docs.python.org/3/library/exceptions.html#ValueError"
  rel="nofollow"
><code>ValueError</code></a> —
If an organization token is passed. Only personal account tokens are valid
to log in.</li>
<li><a
  href="https://docs.python.org/3/library/exceptions.html#ValueError"
  rel="nofollow"
><code>ValueError</code></a> —
If token is invalid.</li>
<li><a
  href="https://docs.python.org/3/library/exceptions.html#ImportError"
  rel="nofollow"
><code>ImportError</code></a> —
If running in a notebook but <code>ipywidgets</code> is not installed.</li>
</ul>
`,raiseType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>ValueError</code> or <code>ImportError</code></p>
`}}),L=new gt({props:{$$slots:{default:[mt]},$$scope:{ctx:Q}}}),H=new gt({props:{$$slots:{default:[_t]},$$scope:{ctx:Q}}}),N=new K({props:{title:"interpreter_login",local:"huggingface_hub.interpreter_login",headingTag:"h2"}}),j=new ue({props:{name:"huggingface_hub.interpreter_login",anchor:"huggingface_hub.interpreter_login",parameters:[{name:"new_session",val:": bool = True"},{name:"write_permission",val:": bool = False"}],parametersDescription:[{anchor:"huggingface_hub.interpreter_login.new_session",description:`<strong>new_session</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
If <code>True</code>, will request a token even if one is already saved on the machine.`,name:"new_session"},{anchor:"huggingface_hub.interpreter_login.write_permission",description:`<strong>write_permission</strong> (<code>bool</code>) &#x2014;
Ignored and deprecated argument.`,name:"write_permission"}],source:"https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/_login.py#L245"}}),O=new K({props:{title:"notebook_login",local:"huggingface_hub.notebook_login",headingTag:"h2"}}),A=new ue({props:{name:"huggingface_hub.notebook_login",anchor:"huggingface_hub.notebook_login",parameters:[{name:"new_session",val:": bool = True"},{name:"write_permission",val:": bool = False"}],parametersDescription:[{anchor:"huggingface_hub.notebook_login.new_session",description:`<strong>new_session</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
If <code>True</code>, will request a token even if one is already saved on the machine.`,name:"new_session"},{anchor:"huggingface_hub.notebook_login.write_permission",description:`<strong>write_permission</strong> (<code>bool</code>) &#x2014;
Ignored and deprecated argument.`,name:"write_permission"}],source:"https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/_login.py#L317"}}),S=new K({props:{title:"logout",local:"huggingface_hub.logout",headingTag:"h2"}}),U=new ue({props:{name:"huggingface_hub.logout",anchor:"huggingface_hub.logout",parameters:[{name:"token_name",val:": typing.Optional[str] = None"}],parametersDescription:[{anchor:"huggingface_hub.logout.token_name",description:`<strong>token_name</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Name of the access token to logout from. If <code>None</code>, will logout from all saved access tokens.`,name:"token_name"}],source:"https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/_login.py#L133",raiseDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<ul>
<li><a
  href="https://docs.python.org/3/library/exceptions.html#ValueError"
  rel="nofollow"
><code>ValueError</code></a> —
If the access token name is not found.</li>
</ul>
`,raiseType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>ValueError</code></p>
`}}),G=new K({props:{title:"auth_switch",local:"huggingface_hub.auth_switch",headingTag:"h2"}}),R=new ue({props:{name:"huggingface_hub.auth_switch",anchor:"huggingface_hub.auth_switch",parameters:[{name:"token_name",val:": str"},{name:"add_to_git_credential",val:": bool = False"}],parametersDescription:[{anchor:"huggingface_hub.auth_switch.token_name",description:`<strong>token_name</strong> (<code>str</code>) &#x2014;
Name of the access token to switch to.`,name:"token_name"},{anchor:"huggingface_hub.auth_switch.add_to_git_credential",description:`<strong>add_to_git_credential</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
If <code>True</code>, token will be set as git credential. If no git credential helper
is configured, a warning will be displayed to the user. If <code>token</code> is <code>None</code>,
the value of <code>add_to_git_credential</code> is ignored and will be prompted again
to the end user.`,name:"add_to_git_credential"}],source:"https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/_login.py#L175",raiseDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<ul>
<li><a
  href="https://docs.python.org/3/library/exceptions.html#ValueError"
  rel="nofollow"
><code>ValueError</code></a> —
If the access token name is not found.</li>
</ul>
`,raiseType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>ValueError</code></p>
`}}),W=new K({props:{title:"auth_list",local:"huggingface_hub.auth_list",headingTag:"h2"}}),B=new ue({props:{name:"huggingface_hub.auth_list",anchor:"huggingface_hub.auth_list",parameters:[],source:"https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/_login.py#L204"}}),J=new pt({props:{source:"https://github.com/huggingface/huggingface_hub/blob/main/docs/source/en/package_reference/authentication.md"}}),{c(){l=s("meta"),T=o(),c=s("p"),I=o(),d(D.$$.fragment),de=o(),V=s("p"),V.innerHTML=Be,fe=o(),F=s("p"),F.innerHTML=Je,pe=o(),d(q.$$.fragment),me=o(),u=s("div"),d(z.$$.fragment),Me=o(),X=s("p"),X.textContent=Ke,De=o(),Y=s("p"),Y.innerHTML=Qe,Ve=o(),Z=s("p"),Z.innerHTML=Xe,Fe=o(),d(L.$$.fragment),qe=o(),d(H.$$.fragment),_e=o(),d(N.$$.fragment),be=o(),w=s("div"),d(j.$$.fragment),ze=o(),ee=s("p"),ee.textContent=Ye,Ne=o(),te=s("p"),te.innerHTML=Ze,je=o(),ne=s("p"),ne.innerHTML=et,$e=o(),d(O.$$.fragment),we=o(),v=s("div"),d(A.$$.fragment),Oe=o(),oe=s("p"),oe.textContent=tt,Ae=o(),ie=s("p"),ie.innerHTML=nt,Se=o(),ae=s("p"),ae.innerHTML=ot,ve=o(),d(S.$$.fragment),ke=o(),k=s("div"),d(U.$$.fragment),Ue=o(),re=s("p"),re.textContent=it,Ge=o(),se=s("p"),se.textContent=at,xe=o(),d(G.$$.fragment),Te=o(),y=s("div"),d(R.$$.fragment),Re=o(),ge=s("p"),ge.textContent=rt,ye=o(),d(W.$$.fragment),Ce=o(),C=s("div"),d(B.$$.fragment),We=o(),le=s("p"),le.textContent=st,Ie=o(),d(J.$$.fragment),Le=o(),he=s("p"),this.h()},l(e){const t=ft("svelte-u9bgzb",document.head);l=g(t,"META",{name:!0,content:!0}),t.forEach(n),T=i(e),c=g(e,"P",{}),P(c).forEach(n),I=i(e),f(D.$$.fragment,e),de=i(e),V=g(e,"P",{"data-svelte-h":!0}),h(V)!=="svelte-hevnjg"&&(V.innerHTML=Be),fe=i(e),F=g(e,"P",{"data-svelte-h":!0}),h(F)!=="svelte-pa4dpn"&&(F.innerHTML=Je),pe=i(e),f(q.$$.fragment,e),me=i(e),u=g(e,"DIV",{class:!0});var $=P(u);f(z.$$.fragment,$),Me=i($),X=g($,"P",{"data-svelte-h":!0}),h(X)!=="svelte-h0rxjs"&&(X.textContent=Ke),De=i($),Y=g($,"P",{"data-svelte-h":!0}),h(Y)!=="svelte-1m8kult"&&(Y.innerHTML=Qe),Ve=i($),Z=g($,"P",{"data-svelte-h":!0}),h(Z)!=="svelte-16fs138"&&(Z.innerHTML=Xe),Fe=i($),f(L.$$.fragment,$),qe=i($),f(H.$$.fragment,$),$.forEach(n),_e=i(e),f(N.$$.fragment,e),be=i(e),w=g(e,"DIV",{class:!0});var x=P(w);f(j.$$.fragment,x),ze=i(x),ee=g(x,"P",{"data-svelte-h":!0}),h(ee)!=="svelte-1rvjqhd"&&(ee.textContent=Ye),Ne=i(x),te=g(x,"P",{"data-svelte-h":!0}),h(te)!=="svelte-1m7vrxs"&&(te.innerHTML=Ze),je=i(x),ne=g(x,"P",{"data-svelte-h":!0}),h(ne)!=="svelte-1kd85oz"&&(ne.innerHTML=et),x.forEach(n),$e=i(e),f(O.$$.fragment,e),we=i(e),v=g(e,"DIV",{class:!0});var E=P(v);f(A.$$.fragment,E),Oe=i(E),oe=g(E,"P",{"data-svelte-h":!0}),h(oe)!=="svelte-bqvn6n"&&(oe.textContent=tt),Ae=i(E),ie=g(E,"P",{"data-svelte-h":!0}),h(ie)!=="svelte-1klz12r"&&(ie.innerHTML=nt),Se=i(E),ae=g(E,"P",{"data-svelte-h":!0}),h(ae)!=="svelte-1kd85oz"&&(ae.innerHTML=ot),E.forEach(n),ve=i(e),f(S.$$.fragment,e),ke=i(e),k=g(e,"DIV",{class:!0});var ce=P(k);f(U.$$.fragment,ce),Ue=i(ce),re=g(ce,"P",{"data-svelte-h":!0}),h(re)!=="svelte-1462z46"&&(re.textContent=it),Ge=i(ce),se=g(ce,"P",{"data-svelte-h":!0}),h(se)!=="svelte-1x6nsdy"&&(se.textContent=at),ce.forEach(n),xe=i(e),f(G.$$.fragment,e),Te=i(e),y=g(e,"DIV",{class:!0});var Ee=P(y);f(R.$$.fragment,Ee),Re=i(Ee),ge=g(Ee,"P",{"data-svelte-h":!0}),h(ge)!=="svelte-1f0oekc"&&(ge.textContent=rt),Ee.forEach(n),ye=i(e),f(W.$$.fragment,e),Ce=i(e),C=g(e,"DIV",{class:!0});var Pe=P(C);f(B.$$.fragment,Pe),We=i(Pe),le=g(Pe,"P",{"data-svelte-h":!0}),h(le)!=="svelte-7p9zq8"&&(le.textContent=st),Pe.forEach(n),Ie=i(e),f(J.$$.fragment,e),Le=i(e),he=g(e,"P",{}),P(he).forEach(n),this.h()},h(){M(l,"name","hf:doc:metadata"),M(l,"content",$t),M(u,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),M(w,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),M(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),M(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),M(y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),M(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,t){r(document.head,l),a(e,T,t),a(e,c,t),a(e,I,t),p(D,e,t),a(e,de,t),a(e,V,t),a(e,fe,t),a(e,F,t),a(e,pe,t),p(q,e,t),a(e,me,t),a(e,u,t),p(z,u,null),r(u,Me),r(u,X),r(u,De),r(u,Y),r(u,Ve),r(u,Z),r(u,Fe),p(L,u,null),r(u,qe),p(H,u,null),a(e,_e,t),p(N,e,t),a(e,be,t),a(e,w,t),p(j,w,null),r(w,ze),r(w,ee),r(w,Ne),r(w,te),r(w,je),r(w,ne),a(e,$e,t),p(O,e,t),a(e,we,t),a(e,v,t),p(A,v,null),r(v,Oe),r(v,oe),r(v,Ae),r(v,ie),r(v,Se),r(v,ae),a(e,ve,t),p(S,e,t),a(e,ke,t),a(e,k,t),p(U,k,null),r(k,Ue),r(k,re),r(k,Ge),r(k,se),a(e,xe,t),p(G,e,t),a(e,Te,t),a(e,y,t),p(R,y,null),r(y,Re),r(y,ge),a(e,ye,t),p(W,e,t),a(e,Ce,t),a(e,C,t),p(B,C,null),r(C,We),r(C,le),a(e,Ie,t),p(J,e,t),a(e,Le,t),a(e,he,t),He=!0},p(e,[t]){const $={};t&2&&($.$$scope={dirty:t,ctx:e}),L.$set($);const x={};t&2&&(x.$$scope={dirty:t,ctx:e}),H.$set(x)},i(e){He||(m(D.$$.fragment,e),m(q.$$.fragment,e),m(z.$$.fragment,e),m(L.$$.fragment,e),m(H.$$.fragment,e),m(N.$$.fragment,e),m(j.$$.fragment,e),m(O.$$.fragment,e),m(A.$$.fragment,e),m(S.$$.fragment,e),m(U.$$.fragment,e),m(G.$$.fragment,e),m(R.$$.fragment,e),m(W.$$.fragment,e),m(B.$$.fragment,e),m(J.$$.fragment,e),He=!0)},o(e){_(D.$$.fragment,e),_(q.$$.fragment,e),_(z.$$.fragment,e),_(L.$$.fragment,e),_(H.$$.fragment,e),_(N.$$.fragment,e),_(j.$$.fragment,e),_(O.$$.fragment,e),_(A.$$.fragment,e),_(S.$$.fragment,e),_(U.$$.fragment,e),_(G.$$.fragment,e),_(R.$$.fragment,e),_(W.$$.fragment,e),_(B.$$.fragment,e),_(J.$$.fragment,e),He=!1},d(e){e&&(n(T),n(c),n(I),n(de),n(V),n(fe),n(F),n(pe),n(me),n(u),n(_e),n(be),n(w),n($e),n(we),n(v),n(ve),n(ke),n(k),n(xe),n(Te),n(y),n(ye),n(Ce),n(C),n(Ie),n(Le),n(he)),n(l),b(D,e),b(q,e),b(z),b(L),b(H),b(N,e),b(j),b(O,e),b(A),b(S,e),b(U),b(G,e),b(R),b(W,e),b(B),b(J,e)}}}const $t='{"title":"Authentication","local":"authentication","sections":[{"title":"login","local":"huggingface_hub.login","sections":[],"depth":2},{"title":"interpreter_login","local":"huggingface_hub.interpreter_login","sections":[],"depth":2},{"title":"notebook_login","local":"huggingface_hub.notebook_login","sections":[],"depth":2},{"title":"logout","local":"huggingface_hub.logout","sections":[],"depth":2},{"title":"auth_switch","local":"huggingface_hub.auth_switch","sections":[],"depth":2},{"title":"auth_list","local":"huggingface_hub.auth_list","sections":[],"depth":2}],"depth":1}';function wt(Q){return ut(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ct extends ht{constructor(l){super(),dt(this,l,wt,bt,ct,{})}}export{Ct as component};
