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

Inference API always returns error: Invalid token #38

Closed
greyblue9 opened this issue Apr 28, 2022 · 4 comments
Closed

Inference API always returns error: Invalid token #38

greyblue9 opened this issue Apr 28, 2022 · 4 comments

Comments

@greyblue9
Copy link

Sorry if this is not the best place to post this issue. I am having an issue with the inference API suddenly, after it has worked perfectly for months:

After seeing '{ "error": "invalid token" }' coming back in response to queries, I created a new API token (old one was not showing up, abd changed the header from Authorization: Bearer api_XXX to Authorization: Bearer hf_YYY as outlined in the docs, but am still facing the same error.

Any idea what could be the issue? I am so hoping this could be fixed soon.

@Narsil
Copy link
Contributor

Narsil commented Apr 29, 2022

Hi @greyblue9 ,

Are you sure you're correctly passing the token ?
We recently changed rules, to be less silent about incorrect tokens especially when formatting was forgotten.
We used to simply pass request as unauthenticated but it caused issues for some users not realizing they had made simple typos and couldn't access their plan features

f"Bearer {API_TOKEN}"  #works
# vs
"Bearer {API_TOKEN}"  # doesn't work, no formatting, `"{API_TOKEN}"` is actually invalid.

Both old and new tokens should work the same way by the way.

Sorry about this issue.

@greyblue9
Copy link
Author

greyblue9 commented Apr 30, 2022

Hi @greyblue9 ,
Both old and new tokens should work the same way by the way.

Thank you so much for your response. I actually created a new account with a new (write) token, and that worked 🤔

What I was using previously, the token was much longer (about 3x longer and had no api_ or hf_ prefix on it, and I was using f"Bearer: api_{token}")

Maybe the : was the issue?

@Narsil
Copy link
Contributor

Narsil commented May 2, 2022

Probably, we really need to get Bearer {API_TOKEN} !

Glad you could work it out.

@Narsil
Copy link
Contributor

Narsil commented May 2, 2022

I will close this, don ´t hesitate to open again if you think it's incorrect.

@Narsil Narsil closed this as completed May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants