无法将 API 密钥与 GCP 的 python 发现客户端一起使用

发布于 2025-01-14 03:44:59 字数 335 浏览 4 评论 0原文

我的问题是我们可以将角色绑定到 API 密钥吗?如果可以的话,如何绑定?

如果不支持哪些服务,那么 GCP 上的所有服务是否都支持 API 密钥?

另外,为什么要使用服务帐户而不是 API 密钥?

from googleapiclient import discovery

storage_service = discovery.build('storage', 'v1', developerKey="AIzaSyhidingKeyVm60c")

storage_service.buckets().list(project='my-project').execute()

my question is can we bind roles to API Keys if so, how?

Are the API Keys supported for all the services across GCP if not which ones?

also, why to use service account over API keys?

from googleapiclient import discovery

storage_service = discovery.build('storage', 'v1', developerKey="AIzaSyhidingKeyVm60c")

storage_service.buckets().list(project='my-project').execute()

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无人接听 2025-01-21 03:44:59

我鼓励您阅读 Google 的文档,例如身份验证概述,它是权威且全面的。

API 密钥:

  • 验证应用程序(而不是用户)。
  • 受 Google(不仅是 Google Cloud Platform)服务的支持。
  • 如果有的话,应该谨慎使用。
  • 不与角色一起使用。

角色是基于角色的访问控制 (RBAC) 的一个元素,对于 Google Cloud IAM(概述< /a>) 绑定到用户、服务帐户和组以定义访问策略。

访问不属于用户的数据的程序通常应作为服务帐户运行。

访问用户拥有的数据的程序应使用用户的凭据进行身份验证。

I encourage you to read Google's documentation, e.g. authentication overview, it is definitive and comprehensive.

API keys:

  • authenticate apps (not users).
  • are supported across Google's (not only Google Cloud Platform) services.
  • should be used judiciously if at all.
  • aren't used with roles.

Roles are an element of role-based access control (RBAC) and, with Google Cloud IAM (overview) are bound to users, service accounts and groups to define access policies.

Programs accessing data not owned by users should generally run as a service account.

Programs accessing data owned by users should authenticate using the user's credentials.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文