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:
Hi @sidsanc,
Welcome to Google Cloud Community!
The error message you are getting signifies that you are encountering permission issues. This typically means that your project does not have the necessary authorization to access or modify the requested resource.
Please ensure that your account has the appropriate access permissions for the required scopes and double-check the authentication method you're using for your specific environment.
The posts below address a similar error message and may be helpful:
For further information about the different authentication methods and use cases, please check the GCP Authentication documentation.
I hope this helps.
User | Count |
---|---|
2 | |
2 | |
1 | |
1 | |
1 |