Unauthorized Access Token

Hi,

Thanks in advance if you’re able to help out.

  • All the code that leads to the problem:
curl -H "Authorization: Bearer hf_<...>bfQ" https://huggingface.co/api/whoami
  • The full error message:
{"error":"Invalid credentials in Authorization header"}
  • Provide the version of the library you are using:
    I’m not using a library for this

  • If you have tried something in particular to solve your problem, don’t hesitate to mention it as well:
    I tried to use the credentials initially in an n8n workflow → http request node. The curl is the simplest way to express this problem.
    Please find attached shot of the tokens I setup:

The error message is clear as to what the problem is (unauthorized). What I do not know is why and/or why Huggingface server interprets the access token as anauthorized?

1 Like

Try v2.

HF_TOKEN = "hf_foobar"
import subprocess
subprocess.run(f'curl -H "Authorization: Bearer {HF_TOKEN}" https://huggingface.co/api/whoami', shell=True)
# {"error":"Invalid credentials in Authorization header"}
subprocess.run(f'curl -H "Authorization: Bearer {HF_TOKEN}" https://huggingface.co/api/whoami-v2', shell=True)
# {"type":"user", ...

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.