{"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,"last_verified":"2026-05-12T13:47:44.274Z","next_check":"2026-06-26T00:00:00.000Z","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,"install_tag":"verified","quickstart_score":0,"quickstart_tag":"stale","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.85,"mem_mb":23.6,"disk_size":"69.8M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.04,"mem_mb":20.4,"disk_size":"68M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.48,"mem_mb":25.6,"disk_size":"74.7M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.53,"mem_mb":22.5,"disk_size":"72M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.54,"mem_mb":24.9,"disk_size":"66.1M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.88,"mem_mb":21.8,"disk_size":"64M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.33,"mem_mb":25.9,"disk_size":"65.6M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.99,"mem_mb":22.7,"disk_size":"63M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.5,"mem_mb":23.4,"disk_size":"69.9M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.18,"mem_mb":20.3,"disk_size":"68M"}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}}