API 키는 키가 생성된 Google Cloud 프로젝트와 연결됩니다. API에 API 키가 필요하면 Cloud Endpoints 서비스를 생성한 프로젝트의 키를 API 사용자에게 제공해야 합니다. 또는 사용자가 자신의 고유 Google Cloud 프로젝트에서 API를 사용 설정하고 API 키를 만들도록 허용할 수 있습니다. 이 페이지에서는 사용자가 API를 사용 설정하기 위해 필요한 권한을 부여하는 방법을 보여줍니다.
액세스 권한 부여
Endpoints는 Identity and Access Management(IAM)서비스 소비자 역할을 사용하여 자체 Google Cloud 프로젝트에서 API를 사용 설정하기 위해 Google Cloud 프로젝트의 구성원이 아닌 다른 사용자를 허용합니다. 이 섹션에서는 Google Cloud 콘솔 또는 Google Cloud CLI를 사용하여 액세스 권한을 부여하는 방법을 보여줍니다.
Google Cloud 콘솔
Google Cloud 콘솔에서 프로젝트의 Endpoints > 서비스 페이지로 이동합니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2024-12-21(UTC)"],[[["\u003cp\u003eAPI 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.\u003c/p\u003e\n"],["\u003cp\u003eGranting 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.\u003c/p\u003e\n"],["\u003cp\u003eTo 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.\u003c/p\u003e\n"],["\u003cp\u003eRevoking 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.\u003c/p\u003e\n"],["\u003cp\u003eThe 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.\u003c/p\u003e\n"]]],[],null,["# Controlling who can enable your API\n\n[OpenAPI](/endpoints/docs/openapi/control-api-callers \"View this page for the Cloud Endpoints OpenAPI docs\") \\| gRPC\n\n\u003cbr /\u003e\n\nAPI keys are associated with the Google Cloud project in which\nthey have been created. If your API requires an API key, you either have to give\nyour API users a key from the project that you created the Cloud Endpoints\nservice in, or you can let users enable your API in their own Google Cloud\nproject and create an API key. This page shows you how to grant the permission\nthat users need to enable your API.\n\nGranting access\n---------------\n\nEndpoints uses the\n[Identity and Access Management (IAM)](/iam/docs)\n**Service Consumer** role to allow someone who isn't a member of your\nGoogle Cloud project to enable your API in their own Google Cloud\nproject. This section shows you how to grant access using the\nGoogle Cloud console or the Google Cloud CLI. \n\n### Google Cloud console\n\n1. In the Google Cloud console, go to the **Endpoints** \\\u003e **Services** page for your project.\n\n\n [Go to the Endpoints Services page](https://console.cloud.google.com/endpoints)\n\n \u003cbr /\u003e\n\n2. If you have more than one API, click the name of the API that you want to grant access to.\n3. If the **Permissions** side panel isn't open, click **Show Permissions Panel**.\n4. In the **Add Principal** field, enter the email address of the person or [Google Group](https://support.google.com/groups/answer/2464926) that you want to grant access to.\n5. In the **Select a role** drop-down menu, select **Service Management** \\\u003e **Service Consumer**.\n6. Click **Save**.\n7. Repeat adding members and selecting the role, as needed.\n8. Contact the users or groups that you added and let them know they can enable the API in their Google Cloud projects. See [Enable an API in your Google Cloud\n project](/endpoints/docs/grpc/enable-api) for information on how to enable a service in APIs \\& services.\n\n### gcloud\n\n1. Open Cloud Shell, or if you have the Google Cloud CLI installed, open a terminal window.\n - If you are granting access to an individual user:\n\n - If you are granting access to a Google Group:\n\n2. Contact the users or groups that you added and let them know they can enable the API in their Google Cloud projects. See [Enable an API in your Google Cloud\n project](/endpoints/docs/grpc/enable-api) for information on how to enable a service in APIs \\& services.\n\nRevoking access\n---------------\n\nYou revoke access to your API by removing the **Service Consumer** role from a\nuser or group that previously had the role. After you revoke someone's access,\nthey won't be able to enable your API.\n| **Note:** If someone has already enabled your API, revoking access doesn't prevent them from calling your API. Although there is no easy way to to prevent these calls, you can add logic to your code that disallows calls from a specific caller's API key.\n\nThis section shows you how to revoke access using the Google Cloud console or\nthe Google Cloud CLI. \n\n### Google Cloud console\n\n1. In the Google Cloud console, go to the **Endpoints** \\\u003e **Services** page for your Google Cloud project.\n\n\n [Go to the Endpoints Services page](https://console.cloud.google.com/endpoints)\n\n \u003cbr /\u003e\n\n2. If you have more than one API, click the name of the API that you want to revoke access to.\n3. If the **Permissions** side panel isn't open, click **addPermissions**.\n4. Click the **Role** card that the member belongs to.\n5. Click **Delete** delete.\n\n### gcloud\n\n- If you are revoking access for an individual user:\n\n- If you are revoking access for a Google Group:\n\nWhat's next\n-----------\n\n- Tell users how to [enable your API in their Google Cloud project](/endpoints/docs/grpc/enable-api).\n\n\u003c!-- --\u003e\n\n- Learn more about [Sharing APIs protected by API keys](/endpoints/docs/grpc/restricting-api-access-with-api-keys#sharing_apis_protected_by_api_key).\n\n\u003c!-- --\u003e\n\n- Create a [Cloud Endpoints Portal](/endpoints/docs/grpc/dev-portal-overview) for your users."]]