Bogus 401 Unauthenticated errors?

Anyone else seen this error?

Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See Integrating Google Sign-In into your web app  |  Authentication  |  Google for Developers.

You would think it means the request had bad authentication, but it’s the same call using the same key that was working for months. And in fact, the same key running the same code in the test-environment works fine.

We tried creating a new key, which worked for a very short time, then started returning the same 401 errors. And again, the new key works in Test. It’s very perplexing.

Hi @stiesell ,
Sounds like the API key is restricted or deprecated. Try switching to OAuth some Gemini endpoints now require it. Check auth settings and quotas.
Using Gemini API keys | Google AI for Developers
Authentication with OAuth quickstart | Gemini API | Google AI for Developers
Thanks!