Google support: Gemini Auth API Key rejected with HTTP 401
Summary
A standalone .NET 10 console application, using only the standard HttpClient and no Gemini SDK, application framework, project dependencies or custom message handlers, reproduces the authentication rejection. The Tactium GeminiProvider returns the same error with the same credential, compared privately in memory.
We request investigation of authentication/key provisioning for project gen-lang-client-06658019... We are not claiming a particular Google backend defect: the specific cause remains unknown. No key value, prefix, suffix, fingerprint, service-account email, internal document, JWT secret or SQL credential is included.
Project configuration
The following was independently inspected in Google Cloud / AI Studio by the project administrator and supplied to this investigation; it was not inferred from the HTTP error:
| Field | Confirmed state |
|---|---|
| Project name | Tactium-Copilot |
| Project ID | gen-lang-client-06658019.. |
| Gemini / Generative Language API | Enabled |
| API key creation | Google AI Studio; rotated replacement |
| API key status | Active |
| API restriction | Gemini API |
| Application restriction | None |
| Bound account | Configured |
| Bound service account | Exists; enabled |
| Billing | Free Tier / not configured, per supplied context |
No billing, OAuth, IAM roles, key restrictions or service-account configuration was changed during reproduction. No service-account JSON key was created.
Independent request and response
- Observed request start UTC: 2026-10-10T16:29:30.1832809Z.
- Google response
Date: 2026-10-10T16:29:30Z. - Endpoint:
https://generativelanguage.googleapis.com/v1beta/models. - Method:
GET; no query string, request body or request Content-Type. - Authentication header:
x-goog-api-key: [REDACTED]. AuthorizationandProxy-Authorization: absent.- Credential forwarded unchanged; not converted into an OAuth Bearer token.
- HTTP status: 401; elapsed: 2359 ms, measured with Stopwatch.
- Google error status: UNAUTHENTICATED.
- Google error reason: ACCESS_TOKEN_TYPE_UNSUPPORTED.
- Sanitized message: Google rejected the authentication credential: access token type unsupported.
- Response Content-Type:
application/json; HTTP version:1.1. - Response
WWW-Authenticate: present; its raw value was not exported. This is a response challenge, not an Authorization header in our request.
Credential configuration was audited. Only the confirmed Windows User GEMINI_API_KEY is configured; no competing Process/Machine aliases or Gemini User Secrets were found. It was imported into child-process memory explicitly and restored afterwards. Structural checks passed: present, 53 characters, plausible length, no whitespace, CR/LF, controls, wrapping quotes or recognized placeholder. No credential characters were trimmed or replaced. These checks establish structural integrity, not backend validity of the key.
Comparison with the actual provider
| Property | Standalone HttpClient | GeminiProvider |
|---|---|---|
| Scheme | https | https |
| Host | generativelanguage.googleapis.com | generativelanguage.googleapis.com |
| API version / path | v1beta / /v1beta/models | v1beta / /v1beta/models |
| Method | GET | GET |
| Query | None | pageSize=1000 |
| API key header | Present; REDACTED | Present; REDACTED |
| Authorization Bearer | Absent | Absent |
| Request Content-Type | N/A, no body | N/A, no body |
| Credential unchanged | Yes | Yes |
| HTTP status | 401 | 401 |
| Error | UNAUTHENTICATED / ACCESS_TOKEN_TYPE_UNSUPPORTED | Identical |
| Elapsed | 2359 ms | 1753 ms |
The page-size query changes catalog pagination, not the authentication method. A further matched REST control with pageSize=1000 also returned the identical error in 916 ms. These were bounded diagnostic comparisons, without automatic retries. No generateContent request was issued after the failed authentication prerequisite. Model availability therefore remains untested; the configured candidate is gemini-2.5-flash.
Minimal reproduction
The reproduction was already executed by Codex. Its source can be shared independently:
It uses .NET 10 and built-in libraries only. There are no package/project references or hardcoded keys. It reads an existing GEMINI_API_KEY process environment variable; the credential is sent solely in the header. All persisted output is sanitized. It calls generateContent only if models.list succeeds and the explicitly configured model is available; only a public synthetic OK prompt is used in that branch.
For a support reproduction environment with its own securely configured key, the procedure is:
dotnet build ValidationTools/GeminiAuthRepro -c Release
dotnet ValidationTools/GeminiAuthRepro/bin/Release/net10.0/GeminiAuthRepro.dll
Do not attach environment dumps, secret values, raw request headers or service-account JSON keys. This report was prepared for possible submission; no ticket or message was automatically sent.
The authentication header follows Google’s current Gemini API key documentation. The error classification follows Google ErrorReason. Please investigate why this credential is rejected despite the administrator-confirmed enabled API, active restricted key and active bound service account.