Google Speech API returns 403 PERMISSION_DENIED

我怕爱的太早我们不能终老 提交于 2019-12-30 09:38:11

问题


I have been using the Google Speech API to transcribe audio to text from my PHP app (using the Google Cloud PHP Client) for several months without any problem. But my calls have now started to return 403 errors with status "PERMISSION_DENIED" and message "The caller does not have permission".

I'm using the Speech API together with Google Storage. I'm authenticating using a service account and sending my audio data to Storage. That's working, the file gets uploaded. So I understand - but I might be wrong? - that "the caller" does not have permission to then read to the audio data from Storage.

I've been playing with permissions through the Google Console without success. I've read the docs but am quite confused. The service account I am using (I guess this is "the caller"?) has owner permissions on the project. And everything used to work fine, I haven't changed a thing.

I'm not posting code because if I understand correctly my app code isn't the issue - it's rather my Google Cloud settings. I'd be grateful for any idea or clarifications of concepts!

Thanks.


回答1:


Being an owner of the project doesn't necessarily imply that the service account has read permission on the object. It's possible that the object was uploaded by another account that specified a private ACL or similar.

Make sure that the service account has access to the object by giving it the right permissions on the entire bucket or on the specific object itself.

You can do so using gsutil acl. More information and additional methods may be found in the official documentation.

For instance the following command gives READ permission on an object to your service account:

gsutil acl -r ch -u serviceAccount@domain.com:R gs://bucket/object

And this command gives READ permission on an entire bucket to your service account:

gsutil acl -r ch -u serviceAccount@domain.com:R gs://bucket



回答2:


In google cloud vision,when your creating credentials with service account key, you have to create role and set it owner and accesses full permissions



来源:https://stackoverflow.com/questions/43943432/google-speech-api-returns-403-permission-denied

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!