Hi Community,
I'm encountering an error while attempting to make a POST request to the Google Generative Language API. I’m working on a project that requires embedding text using the embedding-001 model. Below are the details:
Screenshot of the all the roles provided and enabled for service account:
{
"error": {
"code": 403,
"message": "Request had insufficient authentication scopes.",
"status": "PERMISSION_DENIED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "ACCESS_TOKEN_SCOPE_INSUFFICIENT",
"domain": "googleapis.com",
"metadata": {
"method": "google.ai.generativelanguage.v1beta.GenerativeService.BatchEmbedContents",
"service": "generativelanguage.googleapis.com"
}
}
]
}
}
What I've tried so far:
scopes = ["https://www.googleapis.com/auth/generative-language"]
credentials = service_account.Credentials.from_service_account_file(
service_account_key_path, scopes=scopes
)
credentials.refresh(Request())
Error Response: Despite following the official documentation, I continue to receive the ACCESS_TOKEN_SCOPE_INSUFFICIENT error. I’ve verified the service account and scopes multiple times.
Questions: