简体   繁体   English

如何允许团队成员使用我的 Google Cloud Speech-to-Text API 帐户?

[英]How do I allow a team member to use my Google Cloud Speech-to-Text API account?

I enabled the Google Cloud Speech-to-Text API, but I would like to allow a team member to use it on my account.我启用了 Google Cloud Speech-to-Text API,但我想允许团队成员在我的帐户上使用它。

I went into IAM to add a new user, but I don't see any roles related to Cloud Speech-to-Text API. What IAM role(s) do I need to select to allow the new team member access to the API?我进入 IAM 以添加新用户,但我没有看到任何与 Cloud Speech-to-Text API 相关的角色。我需要哪些 IAM 角色 select 才能允许新团队成员访问 API?

Text-to-speech API is a special (old?) API at Google and doesn't require role.文字转语音 API 是 Google 的一个特殊(旧?)API,不需要角色。 The API URL also doesn't require project definition. API URL 也不需要项目定义。 So, you need an account linked to the project to be able to reach the Speech-to-text API.因此,您需要一个链接到该项目的帐户才能访问 Speech-to-text API。

For this, the "service-account" account is the account to use.为此,“服务帐户”帐户是要使用的帐户。 So, the users need to use a service account to reach the API. To prevent the service account key file generation (source of potential security issue), prefer the impersonation .因此,用户需要使用服务帐户才能到达 API。为防止服务帐户密钥文件生成(潜在安全问题的来源),更喜欢模拟

With the gcloud cli you can do this to generate a valid access-token on behalf of the service account.使用 gcloud cli,您可以执行此操作以代表服务帐户生成有效的访问令牌。

gcloud auth print-access-token --impersonate-service-account=<the service account to impersonate>

So, in your API call, from your computer (I mean with your own user credential) you can do like this所以,在你的 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM