I received a permission error when attempting to call Google speech-to-text v2 API even though I made sure to authenticate with a service account beforehand.
API Call Response:
{
"error": {
"code": 403,
"message": "Permission 'speech.recognizers.recognize' denied on resource (or it may not exist).",
"status": "PERMISSION_DENIED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "IAM_PERMISSION_DENIED",
"domain": "iam.googleapis.com",
"metadata": {
"permission": "speech.recognizers.recognize"
}
}
]
}
}
I've gone through the docs and done the following:
API Call Endpoint:
"https://{Location}-speech.googleapis.com/v2/projects/{Project ID}/locations/{Recognizer Location}/recognizers/{Recognizer Name}:recognize?access_token={Access Token}"
API Call Headers:
["Authorization: Bearer", "Content-Type: audio/wav", "accept: */*"]
I was expecting to have the permission to call the API since I already authenticated using a service account with the necessary roles/permissions with the necessary scope.
More Info:
You also have to specify the access token in the headers: "Authorization: Bearer {access token}"