API access always returns 401 Invalid credentials

Hello, I recently created a Hugging Face account and verified my email. I have generated multiple access tokens with read permissions, but every attempt to call the API endpoint https://huggingface.co/api/whoami fails with:

{“error”:“Invalid credentials in Authorization header”}

I’ve tried:

  • Multiple tokens
  • Logging out and logging back in
  • Deleting cookies and trying from incognito mode
  • Verifying that the token is active
  • Using curl and Python requests

But nothing works. Could you check if my account has an API restriction or if something else is wrong?

Thank you.

1 Like

Try https://huggingface.co/api/whoami-v2
Hub API Endpoints