{"id":434,"library":"google-cloud-secret-manager","title":"Google Cloud Secret Manager Client Library","description":"A Python client library for Google Cloud Secret Manager, enabling secure storage and management of application secrets. Current version: 2.27.0. Released on a regular cadence, with recent updates enhancing functionality and security features.","status":"active","version":"2.27.0","language":"python","source_language":"en","source_url":"https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-secret-manager","tags":["google-cloud","secret-manager","python","client-library"],"install":[{"cmd":"pip install google-cloud-secret-manager","lang":"bash","label":"Install google-cloud-secret-manager"}],"dependencies":[{"reason":"Required for authentication with Google Cloud services.","package":"google-auth","optional":false},{"reason":"Provides core functionality for Google API client libraries.","package":"google-api-core","optional":false},{"reason":"Contains common code for Google Cloud client libraries.","package":"google-cloud-core","optional":false}],"imports":[{"note":"Ensure to import from 'secretmanager_v1' for the latest features and fixes.","symbol":"SecretManagerServiceClient","correct":"from google.cloud import secretmanager_v1"}],"quickstart":{"code":"import os\nfrom google.cloud import secretmanager_v1\n\n# Set up authentication\nos.environ['GOOGLE_APPLICATION_CREDENTIALS'] = 'path_to_your_service_account_file.json'\n\n# Initialize the Secret Manager client\nclient = secretmanager_v1.SecretManagerServiceClient()\n\n# Define project and secret details\nproject_id = 'your-project-id'\nsecret_id = 'your-secret-id'\n\n# Build the parent name from the project\nparent = f'projects/{project_id}'\n\n# Create the secret\nsecret = client.create_secret(\n    request={\n        'parent': parent,\n        'secret_id': secret_id,\n        'secret': {'replication': {'automatic': {}}},\n    }\n)\n\n# Add a version with a payload\nversion = client.add_secret_version(\n    request={\n        'parent': secret.name,\n        'payload': {'data': b'hello world!'},\n    }\n)\n\n# Access the secret version\nresponse = client.access_secret_version(request={'name': version.name})\n\n# Print the secret payload\npayload = response.payload.data.decode('UTF-8')\nprint(f'Plaintext: {payload}')","lang":"python","description":"A complete example demonstrating how to create a secret, add a version, and access the secret's payload using the Google Cloud Secret Manager client library."},"warnings":[{"fix":"Update import statements to 'from google.cloud import secretmanager_v1'.","message":"Import path changed from 'google.cloud import secretmanager' to 'google.cloud import secretmanager_v1'.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Transition to 'secretmanager_v1' to ensure compatibility with future versions.","message":"Using 'secretmanager' instead of 'secretmanager_v1' may lead to compatibility issues in future releases.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Set the 'GOOGLE_APPLICATION_CREDENTIALS' environment variable to the path of your service account JSON file.","message":"Ensure that the 'GOOGLE_APPLICATION_CREDENTIALS' environment variable points to a valid service account JSON file for authentication.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'2.27.0':26 'applic':22 'cadenc':31 'client':5,9,48 'client-librari':47 'cloud':2,13,42 'current':24 'enabl':16 'enhanc':35 'featur':39 'function':36 'googl':1,12,41 'google-cloud':40 'librari':6,10,49 'manag':4,15,20,45 'python':8,46 'recent':33 'regular':30 'releas':27 'secret':3,14,23,44 'secret-manag':43 'secur':17,38 'storag':18 'updat':34 'version':25","created_at":"2026-03-28T12:02:25.423929+00:00","updated_at":"2026-04-16T15:23:56.478682+00:00","problems":[{"fix":"Install the library using pip: `pip install google-cloud-secret-manager`","cause":"The `google-cloud-secret-manager` library is not installed in the Python environment, or the environment (e.g., a specific runtime in a cloud service) cannot locate the installed package.","error":"ModuleNotFoundError: No module named 'google.cloud.secretmanager'"},{"fix":"Ensure the library is properly installed: `pip install google-cloud-secret-manager`. If issues persist, verify your Python environment and package paths, especially in isolated environments like virtual machines or containers.","cause":"This typically occurs when the `google-cloud-secret-manager` package is not correctly installed or its components are not accessible within the `google.cloud` namespace, sometimes due to conflicts with other `google.cloud` packages or environment issues.","error":"ImportError: cannot import name 'secretmanager' from 'google.cloud'"},{"fix":"Grant the appropriate IAM role (e.g., 'Secret Manager Secret Accessor') to the service account or user identity on the specific secret or its parent resource (project/folder/organization).","cause":"The service account or user identity attempting to access the secret lacks the necessary IAM permissions, such as 'Secret Manager Secret Accessor' (`roles/secretmanager.secretAccessor`) for the secret, project, or folder.","error":"Permission denied (or similar error message indicating missing permissions like 'secretmanager.versions.accessSecretVersion')"},{"fix":"Access the secret data via `response.payload.data.decode('utf-8')` after retrieving the secret version, where `response` is the `SecretVersion` object.","cause":"After retrieving a `SecretVersion` object, the actual secret data is stored within its `payload.data` attribute, not directly in a `payload` attribute of the `SecretVersion` object itself.","error":"AttributeError: 'SecretVersion' object has no attribute 'payload'"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"quickstart_score":0,"quickstart_tag":"stale","pypi_latest":"2.30.0","cli_name":"","cli_version":null,"type":"library","homepage":"https://cloud.google.com/secret-manager","github":"https://github.com/googleapis/google-cloud-python","docs":null,"changelog":null,"pypi":"https://pypi.org/project/google-cloud-secret-manager/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["gcp","auth-security"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-27","next_check":"2026-07-28","install_tag":"verified"}}