API 金鑰與建立金鑰時所屬的 Google Cloud 專案相關聯。如果您的 API 需要 API 金鑰,您就必須提供 API 使用者 Cloud Endpoints 服務建立時所屬專案中的金鑰,或是讓 API 使用者能夠在自己的專案中啟用您的 API 及建立 API 金鑰。 Google Cloud本頁說明如何授權使用者啟用您的 API。
授予存取權
Endpoints 會使用 Identity & Access Management (IAM)服務消費者角色,允許您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"]],["上次更新時間:2025-05-29 (世界標準時間)。"],[[["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."]]],[]]