Huggingface token returning an invalid token

Hello,
Today I have been getting the following error while training models in Sagemaker. I am passing the exact same token that I was passing yesterday

The following is the error message.

!huggingface-cli login --token {HF_TOKEN}

Token will not been saved to git credential helper. Pass `add_to_git_credential=True` if you want to set the git credential as well.
Traceback (most recent call last):
  File "/home/ec2-user/anaconda3/envs/pytorch_p310/bin/huggingface-cli", line 8, in <module>
    sys.exit(main())
  File "/home/ec2-user/anaconda3/envs/pytorch_p310/lib/python3.10/site-packages/huggingface_hub/commands/huggingface_cli.py", line 45, in main
    service.run()
  File "/home/ec2-user/anaconda3/envs/pytorch_p310/lib/python3.10/site-packages/huggingface_hub/commands/user.py", line 101, in run
    login(token=self.args.token, add_to_git_credential=self.args.add_to_git_credential)
  File "/home/ec2-user/anaconda3/envs/pytorch_p310/lib/python3.10/site-packages/huggingface_hub/_login.py", line 96, in login
    _login(token, add_to_git_credential=add_to_git_credential, write_permission=write_permission)
  File "/home/ec2-user/anaconda3/envs/pytorch_p310/lib/python3.10/site-packages/huggingface_hub/_login.py", line 275, in _login
    raise ValueError("Invalid token passed!")
ValueError: Invalid token passed!

@philschmid

2 Likes

You can try in any kind of notebook

import subprocess
subprocess.run(["huggingface-cli", "login", "--token", HF_TOKEN])