【发布时间】:2021-01-14 04:52:58
【问题描述】:
我启用了 Google Cloud Speech-to-Text API,但我想允许团队成员在我的帐户上使用它。
我进入 IAM 添加新用户,但我没有看到任何与 Cloud Speech-to-Text API 相关的角色。我需要选择哪些 IAM 角色才能允许新团队成员访问 API?
【问题讨论】:
标签: google-cloud-platform google-iam google-cloud-iam
我启用了 Google Cloud Speech-to-Text API,但我想允许团队成员在我的帐户上使用它。
我进入 IAM 添加新用户,但我没有看到任何与 Cloud Speech-to-Text API 相关的角色。我需要选择哪些 IAM 角色才能允许新团队成员访问 API?
【问题讨论】:
标签: google-cloud-platform google-iam google-cloud-iam
Text-to-speech API 是 Google 的一个特殊(旧?)API,不需要角色。 API URL 也不需要项目定义。因此,您需要一个与项目相关联的帐户才能访问 Speech-to-text API。
为此,“服务帐户”帐户是要使用的帐户。因此,用户需要使用服务帐户来访问 API。为防止生成服务帐户密钥文件(潜在安全问题的来源),请首选impersonation。
使用 gcloud cli,您可以执行此操作以代表服务帐户生成有效的访问令牌。
gcloud auth print-access-token --impersonate-service-account=<the service account to impersonate>
因此,在您的 API 调用中,您可以从您的计算机(我的意思是使用您自己的用户凭据)执行这样的操作
curl -d @inputdata -H "content-type: application/json" \
-H "Authorization: Bearer $(gcloud auth print-access-token --impersonate-service-account=<the service account to impersonate>)" \
https://speech.googleapis.com/v1/speech:recognize
【讨论】: