如要在 Gemini Enterprise Agent Platform 使用 Gemini,請使用 Cloud de Confiance by S3NS API 金鑰或應用程式預設憑證進行驗證。建議您使用 API 金鑰進行測試,並使用應用程式預設憑證進行實際工作環境。本頁說明如何設定應用程式預設憑證。
事前準備
選取專案、啟用帳單、啟用 Agent Platform API、安裝 gcloud CLI
-
In the Cloud de Confiance console, on the project selector page, select or create a Cloud de Confiance project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Cloud de Confiance project.
Enable the Agent Platform API, if it is not already enabled.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.-
Install the Google Cloud CLI.
-
Configure the gcloud CLI to use your federated identity.
For more information, see Sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
建立本機驗證憑證
控制台
為使用者帳戶建立本機驗證憑證:
gcloud auth application-default login
如果系統傳回驗證錯誤,請確認您已 使用聯合身分登入 gcloud CLI。
curl
執行下列指令來安裝及執行 gcloud,設定應用程式預設憑證:
bash <(curl -sSL https://storage.googleapis.com/cloud-samples-data/adc/setup_adc.sh)提出第一項 API 要求
設定應用程式預設憑證後,請參閱 API 快速入門導覽課程,瞭解如何發出第一個要求。