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

查看:111
本文介绍了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.

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

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

此命令将整个存储桶的READ权限授予您的服务帐户:

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天全站免登陆