You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add multi token support
* Set git credentials when setting the active profile
* Add git credential flag as argument for auth switch method
* Fix logout helper function
* Refactor auth utils + fixes
* Remove unnecessary file creation
* Add tests and some fixes
* Make get profiles helper function public
* Add multiselect menu for auth switch command
* Move auth fixture
* Refactor logout helper function
* Update package reference and quick start documentation
* Update cli documentation
* Expose new auth methods in huggingface_hub module
* Multiple small fixes
* post-review fixes
* Fix table of contents
* Use server provided token names instead of profiles
* Add stored tokens path in the environment info
* Multiple fixes post-review
Copy file name to clipboardExpand all lines: docs/source/en/guides/cli.md
+11-9Lines changed: 11 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -92,7 +92,7 @@ Once you have your token, run the following command in your terminal:
92
92
>>> huggingface-cli login
93
93
```
94
94
95
-
This command will prompt you for a token. Copy-paste yours and press *Enter*. Then you'll be asked if the token should also be saved as a git credential. Press *Enter* again (default to yes) if you plan to use `git` locally. Finally, it will call the Hub to check that your token is valid and save it locally.
95
+
This command will prompt you for a token. Copy-paste yours and press *Enter*. Then, you'll be asked if the token should also be saved as a git credential. Press *Enter* again (default to yes) if you plan to use `git` locally. Finally, it will call the Hub to check that your token is valid and save it locally.
The token `token_name` has been saved to /home/wauplin/.cache/huggingface/stored_tokens
119
120
Your token has been saved in your configured git credential helpers (store).
120
121
Your token has been saved to /home/wauplin/.cache/huggingface/token
121
122
Login successful
123
+
The current active token is: `token_name`
122
124
```
123
125
124
126
For more details about authentication, check out [this section](../quick-start#authentication).
@@ -137,7 +139,7 @@ If you are not logged in, an error message will be printed.
137
139
138
140
## huggingface-cli logout
139
141
140
-
This commands logs you out. In practice, it will delete the token saved on your machine.
142
+
This commands logs you out. In practice, it will delete all tokens stored on your machine. If you want to remove a specific token, you can specify the token name as an argument.
141
143
142
144
This command will not log you out if you are logged in using the `HF_TOKEN` environment variable (see [reference](../package_reference/environment_variables#hftoken)). If that is the case, you must unset the environment variable in your machine configuration.
To delete files from a repo you must be authenticated and authorized. By default, the token saved locally (using `huggingface-cli login`) will be used. If you want to authenticate explicitly, use the `--token` option:
Copy file name to clipboardExpand all lines: docs/source/en/package_reference/authentication.md
+10-2Lines changed: 10 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,9 +2,9 @@
2
2
rendered properly in your Markdown viewer.
3
3
-->
4
4
5
-
# Login and logout
5
+
# Authentication
6
6
7
-
The `huggingface_hub` library allows users to programmatically login and logout the machine to the Hub.
7
+
The `huggingface_hub` library allows users to programmatically manage authentication to the Hub. This includes logging in, logging out, switching between tokens, and listing available tokens.
8
8
9
9
For more details about authentication, check out [this section](../quick-start#authentication).
10
10
@@ -23,3 +23,11 @@ For more details about authentication, check out [this section](../quick-start#a
Copy file name to clipboardExpand all lines: docs/source/en/quick-start.md
+13Lines changed: 13 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -93,6 +93,19 @@ Once logged in, all requests to the Hub - even methods that don't necessarily re
93
93
94
94
</Tip>
95
95
96
+
### Manage multiple tokens locally
97
+
98
+
You can save multiple tokens on your machine by simply logging in with the [`login`] command with each token. If you need to switch between these tokens locally, you can use the [`auth switch`] command:
99
+
100
+
```bash
101
+
huggingface-cli auth switch
102
+
```
103
+
104
+
This command will prompt you to select a token by its name from a list of saved tokens. Once selected, the chosen token becomes the _active_ token, and it will be used for all interactions with the Hub.
105
+
106
+
107
+
You can list all available access tokens on your machine with `huggingface-cli auth list`.
108
+
96
109
### Environment variable
97
110
98
111
The environment variable `HF_TOKEN` can also be used to authenticate yourself. This is especially useful in a Space where you can set `HF_TOKEN` as a [Space secret](https://huggingface.co/docs/hub/spaces-overview#managing-secrets).
0 commit comments