Gemini API Key returns 401 ACCESS_TOKEN_TYPE_UNSUPPORTED

,

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].
  • Authorization and Proxy-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.

Hello @Paulo_Guilherme ,

  1. Could you please try creating an API key in a new project within the Google AI Studio UI to check whether the issue is specific to your current project.

  2. If the error persists, please share the full JSON error response (including all details and metadata fields) along with your Google Cloud Project ID or Project Number so we can investigate further.

Hi Pooja, thank you for the suggestion.

I created a brand-new Google AI Studio project and generated a new API key there.

I have now confirmed the new key from the same shell environment using both curl and a direct .NET HttpClient harness.

GET /v1beta/models returns HTTP 200 with both clients, and gemini-3.8-flash is listed as available. Therefore, the original 401 UNAUTHENTICATED / ACCESS_TOKEN_TYPE_UNSUPPORTED does not reproduce with the new project/API key.

I also tested gemini-3.8-flash using both APIs:

  • generateContent: 3 controlled attempts, all returned HTTP 503 with a temporary high-demand response.
  • Interactions API: 3 controlled attempts, all returned HTTP 503 with the same high-demand/service-unavailable behavior.

An earlier isolated diagnostic process returned 401, but I traced that to a different inherited process environment. Running the same harness directly from the shell containing the confirmed new API key returned HTTP 200 for models.list.

So at this point, the original authentication issue appears isolated to the previous project/key. The new project authenticates successfully, while generation on gemini-3.8-flash is currently blocked only by the temporary 503 high-demand condition.

Could you please confirm whether this level of 503 availability is expected for new projects at the moment, or whether there is any additional diagnostic information you would like me to provide?

I can provide the relevant Project ID/number privately through an appropriate channel if needed. I will not publish credentials.