require "infisical"client = Infisical::Client.new# Authenticate with a machine identityclient.auth.universal_auth_login( client_id: ENV.fetch("INFISICAL_CLIENT_ID"), client_secret: ENV.fetch("INFISICAL_CLIENT_SECRET"))# Fetch a secret by namesecret = client.secrets.get( "API_KEY", project_id: "YOUR_PROJECT_ID", environment: "dev")puts secret.secret_value
This example demonstrates how to use the Infisical Ruby SDK in a simple Ruby application. The application retrieves a secret named API_KEY from the dev environment of the YOUR_PROJECT_ID project.
We do not recommend hardcoding your Machine Identity
Tokens. Setting it as
an environment variable would be best.
The SDK authenticates as a machine identity. The most common authentication method is Universal Auth, which uses a client ID and client secret. If you already have a valid access token, you can also set it on the client directly.
Log in with a machine identity’s client ID and client secret. On success, the returned access token is stored on the client and used for all subsequent requests.
client.secrets.update(secret_name, options)Update an existing secret’s value, rename it, or both. You must provide at least one of secret_value or new_secret_name, otherwise an ArgumentError is raised. Returns the updated secret.
client.secrets.delete(secret_name, options)Delete a secret by name. Raises Infisical::NotFoundError if the secret does not exist. Returns the deleted secret.