[[["易于理解","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-09-04。"],[],[],null,["# Access the Secret Manager API\n\nWe recommend that you access Secret Manager API using the following tools:\n\n- The [Google Cloud CLI](/sdk/gcloud/reference/secrets), which provides a\n command-line interface for managing secrets.\n\n- Convenient, idiomatic [Secret Manager client libraries](/secret-manager/docs/reference/libraries), which lets you access and manage\n secrets from within your application source code. Client libraries are available\n in many languages including C#(.NET), Go, Java, Node.js, PHP, Python, and Ruby.\n\nBefore you begin\n----------------\n\n1. [Enable the Secret Manager API](/secret-manager/docs/configuring-secret-manager).\n\n2. Requests to the Secret Manager API require authentication. For\n information, see\n [Set up authentication for Secret Manager](/secret-manager/docs/authentication#authn-how-to).\n\nUse Secret Manager with Compute Engine and Google Kubernetes Engine\n-------------------------------------------------------------------\n\nTo use Secret Manager with workloads running on Compute Engine\nor GKE, the underlying instance or node must have the\n`cloud-platform` OAuth scope. If you receive an error with the following\nmessage, it means the instance or node was not provisioned with the correct\nOAuth scopes. \n\n Request had insufficient authentication scopes\n\nThe required OAuth scope to use Secret Manager is: \n\n https://www.googleapis.com/auth/cloud-platform\n\nWhen creating a new instance, instance group, or node pool,\n[specify the `cloud-platform` scope](/compute/docs/access/create-enable-service-accounts-for-instances#using): \n\n### gcloud\n\n gcloud compute instances create \"\u003cvar translate=\"no\"\u003eINSTANCE_ID\u003c/var\u003e\" \\\n --scopes \"https://www.googleapis.com/auth/cloud-platform\"\n\nFor an existing instance, instance group, or node pool,\n[update the access scopes](/compute/docs/access/create-enable-service-accounts-for-instances#changeserviceaccountandscopes): \n\n### gcloud\n\n gcloud compute instances set-service-account \"\u003cvar translate=\"no\"\u003eINSTANCE_ID\u003c/var\u003e\" \\\n --service-account \"\u003cvar translate=\"no\"\u003eSERVICE_ACCOUNT_EMAIL\u003c/var\u003e\" \\\n --scopes \"https://www.googleapis.com/auth/cloud-platform\"\n\nSee the\n[Compute Engine service account permissions](/compute/docs/access/service-accounts#service_account_permissions)\nfor more information.\n\nUse Secret Manager with App Engine\n----------------------------------\n\nTo use Secret Manager with workloads running on App Engine, you must\ngrant any [required permissions](/secret-manager/docs/access-control#roles) to the\nApp Engine service.\n\nWhat's next\n-----------\n\n- Learn more about [managing access to Secret Manager resources with IAM](/secret-manager/docs/access-control).\n- Learn how to [create a secret and access a secret version](/secret-manager/docs/create-secret-quickstart)."]]