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-05-13。"],[[["API access is granted by assigning the **Service Consumer** role from Identity and Access Management (IAM) to users or Google Groups, allowing them to enable the API in their own Google Cloud projects."],["The Google Cloud console or the gcloud command-line tool can be used to add a user or group to the **Service Consumer** role, which then allows them to access an API."],["Access to an API can be revoked by removing the **Service Consumer** role from a user or group using either the Google Cloud console or gcloud commands, but it does not stop users who have already enabled the API from calling it."],["Once access is granted, users should be informed and directed on how to enable the API in their Google Cloud projects."],["API Keys are linked to a specific Google cloud project, where the API was created, and can be shared for API access, or users can create their own in their respective projects."]]],[]]