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-flashandgemini-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
-
Confirmed that the API key is present in the running Docker container, with no leading or trailing whitespace, surrounding quotes, or internal whitespace.
-
Confirmed that the key is associated with the intended Google Cloud project.
-
Confirmed that the Generative Language API is enabled in that project.
-
Confirmed that the associated service account is enabled.
-
Confirmed that the API key’s API restriction is set to Gemini API. Application restrictions are set to None.
-
Tested both
gemini-2.0-flashandgemini-2.5-flash. -
Reproduced the same authentication failure using the official Python SDK and a direct REST request with the
x-goog-api-keyheader.
Questions
-
Is this error expected for any particular authorization-key provisioning or project configuration issue?
-
Is there a known compatibility issue involving
AQ.authorization keys andgoogle-genai==1.67.0? -
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.