Google Speech API 返回 403 PERMISSION_DENIED [英] Google Speech API returns 403 PERMISSION_DENIED

查看:28
本文介绍了Google Speech API 返回 403 PERMISSION_DENIED的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几个月来,我一直在使用 Google Speech API 将我的 PHP 应用程序(使用 Google Cloud PHP 客户端)中的音频转录为文本,没有任何问题.但是我的调用现在开始返回 403 错误,状态为PERMISSION_DENIED"和消息调用者没有权限".

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".

我将 Speech API 与 Google Storage 一起使用.我正在使用服务帐户进行身份验证并将我的音频数据发送到存储.这是工作,文件被上传.所以我明白了——但我可能是错的?- 调用者"没有权限从存储中读取音频数据.

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.

我一直在通过 Google 控制台使用权限,但没有成功.我已经阅读了文档,但很困惑.我正在使用的服务帐户(我猜这是调用者"?)对项目具有所有者权限.而且过去一切正常,我什么都没改变.

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.

我没有发布代码,因为如果我理解正确,我的应用代码不是问题 - 而是我的 Google Cloud 设置.如有任何想法或概念澄清,我将不胜感激!

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!

谢谢.

推荐答案

作为项目的所有者并不一定意味着服务帐户对该对象具有读取权限.该对象可能是由另一个指定私有 ACL 或类似的帐户上传的.

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.

您可以使用 gsutil acl 执行此操作.更多信息和其他方法可以在 官方文档.

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

例如,以下命令将对象的 READ 权限授予您的服务帐户:

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

这篇关于Google Speech API 返回 403 PERMISSION_DENIED的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆