API 密钥与其创建时所在的 Google Cloud 项目相关联。如果您的 API 需要 API 密钥,则您必须向您的 API 用户提供密钥(该密钥源自您在其中创建 Cloud Endpoints 服务的项目),或者让用户在各自的 Google Cloud项目中启用您的 API 并创建 API 密钥。本页面介绍如何授予用户启用 API 所需的权限。
授予访问权限
Endpoints 使用 Identity and Access Management (IAM)Service Consumer 角色,令非Google Cloud 项目成员能够在各自的 Google Cloud项目中启用您的 API。本部分介绍如何使用 Google Cloud 控制台或 Google Cloud CLI 授予访问权限。
Google Cloud 控制台
在 Google Cloud 控制台中,前往项目的 Endpoints > Services 页面。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-04-02。"],[[["API keys are linked to the Google Cloud project where they were created, allowing users to use keys from the service's project or enable the API in their own project."],["Granting access to an API for others' Google Cloud projects is done using the Identity and Access Management (IAM) Service Consumer role, assignable through the Google Cloud console or the Google Cloud CLI."],["To grant access, you need to add the email or Google Group to the service and assign them the 'Service Consumer' role, and then notify the added users that they can now enable the API."],["Revoking access involves removing the Service Consumer role from the user or group via the Google Cloud console or the gcloud command, preventing them from enabling the API, but not impacting existing users."],["The documentation provides further steps to inform users on how to enable the API on their side, along with more information on sharing API keys and the Cloud Endpoints portal."]]],[]]