Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add token and git credentials to login cli command #1372

Merged
merged 2 commits into from
Mar 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/huggingface_hub/commands/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ class UserCommands(BaseHuggingfaceCLICommand):
@staticmethod
def register_subcommand(parser: _SubParsersAction):
login_parser = parser.add_parser("login", help="Log in using a token from huggingface.co/settings/tokens")
login_parser.add_argument(
"--token",
type=str,
help="Token generated from https://huggingface.co/settings/tokens",
)
login_parser.add_argument(
"--add-to-git-credential",
action="store_true",
help="Optional: Save token to git credential helper.",
)
login_parser.set_defaults(func=lambda args: LoginCommand(args))
whoami_parser = parser.add_parser("whoami", help="Find out which huggingface.co account you are logged in as.")
whoami_parser.set_defaults(func=lambda args: WhoamiCommand(args))
Expand Down Expand Up @@ -91,7 +101,7 @@ def __init__(self, args):

class LoginCommand(BaseUserCommand):
def run(self):
login()
login(token=self.args.token, add_to_git_credential=self.args.add_to_git_credential)


class LogoutCommand(BaseUserCommand):
Expand Down