Create, inspect, update, and delete Google Cloud Secret Manager secrets and their versions directly from R. The package wraps the Secret Manager API v1 and uses 'gargle' for authentication, supporting interactive OAuth, service account keys, and pre-existing tokens. Secret and version metadata are returned as S3 objects with print methods that avoid revealing secret values, and listing operations return data frames with one row per secret or version. Default project settings, labels, filters, and the full version lifecycle (add, access, enable, disable, and delete) are supported.
Keep your secrets safe and sound in the cloud! 🚀
An R package that makes it easy and secure to manage your secrets using Google Cloud Secret Manager. Whether you're building a Shiny app, running R scripts in production, or managing sensitive configuration, googlesecretmanager has got you covered!
# Install the package
remotes::install_github("brancengregory/googlesecretmanager")
# Load and authenticate (opens browser)
library(googlesecretmanager)
gargle::credentials_app_default()
# Start managing secrets!
sm_project_set("my-project-id")
sm_secret_create("api-key", replication = list(automatic = list()))
sm_secret_version_add("api-key", "your-secret-value")
You can install the development version of googlesecretmanager from GitHub using:
# install.packages("remotes")
remotes::install_github("brancengregory/googlesecretmanager")
This package uses gargle for secure authentication with Google Cloud. Choose your preferred method:
library(googlesecretmanager)
gargle::credentials_app_default() # Opens browser for authentication
library(googlesecretmanager)
gargle::credentials_service_account(
path = "path/to/service-account-key.json"
)
library(googlesecretmanager)
token <- gargle::token_fetch(
scopes = "https://www.googleapis.com/auth/cloud-platform"
)
googlesecretmanager_auth(token = token)
# Store an API key
sm_secret_create("stripe-api-key")
sm_secret_version_add("stripe-api-key", "sk_live_...")
# Retrieve in your application
api_key <- sm_secret_version_access("stripe-api-key")
# Store database credentials
db_config <- list(
host = "db.example.com",
user = "admin",
password = "secret123"
)
sm_secret_create("db-config")
sm_secret_version_add("db-config", jsonlite::toJSON(db_config))
# Use in your application
config <- jsonlite::fromJSON(sm_secret_version_access("db-config"))
# Add a new version
sm_secret_version_add("api-key", "new-secret-value")
# List versions
versions <- sm_secret_version_ls("api-key")
# Delete old versions
sm_secret_version_delete("api-key", "old-version-id")
Authentication Failed
Secret Not Found
Permission Denied
This package is built with:
Contributions are welcome! Please:
This project is licensed under the MIT License - see the LICENSE file for details.