Gemini API returns 401 ACCESS_TOKEN_TYPE_UNSUPPORTED with an AI Studio AQ. authorization key

Hello Google AI Developers team,

I’m troubleshooting an authentication failure while integrating the Gemini API into a Python-based application running in Docker. I would appreciate help identifying why the API rejects my authorization key.

Environment

  • OS: Windows, running the application through Docker Compose

  • Python SDK: google-genai==1.67.0

  • Key type: Google AI Studio authorization key (AQ. format)

  • Models tested: gemini-2.0-flash and gemini-2.5-flash

  • API endpoint: generativelanguage.googleapis.com/v1beta/models/{model}:generateContent

Error

Both the Python SDK and a direct REST request return HTTP 401 with the following error:

UNAUTHENTICATED

ACCESS_TOKEN_TYPE_UNSUPPORTED

The response message states that the request has invalid authentication credentials and refers to OAuth 2 access tokens or other valid authentication credentials.

Troubleshooting completed

  1. Confirmed that the API key is present in the running Docker container, with no leading or trailing whitespace, surrounding quotes, or internal whitespace.

  2. Confirmed that the key is associated with the intended Google Cloud project.

  3. Confirmed that the Generative Language API is enabled in that project.

  4. Confirmed that the associated service account is enabled.

  5. Confirmed that the API key’s API restriction is set to Gemini API. Application restrictions are set to None.

  6. Tested both gemini-2.0-flash and gemini-2.5-flash.

  7. Reproduced the same authentication failure using the official Python SDK and a direct REST request with the x-goog-api-key header.

Questions

  1. Is this error expected for any particular authorization-key provisioning or project configuration issue?

  2. Is there a known compatibility issue involving AQ. authorization keys and google-genai==1.67.0?

  3. Are there additional checks or a supported recovery procedure for this error?

I have not included the API key or other credentials in this post. I can provide sanitized diagnostic details if needed.

Thank you for your help.

Hello @Safdar_Raza ,

  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.

It was resolved. Thank you @Pooja_Kapse