Basic Usage
API_KEY from the dev environment of the YOUR_PROJECT_ID project.
Installation
Configuration
Import the SDK and create a client instance.Configuration Options
object
Automatic token refreshing
The Infisical Go SDK supports automatic token refreshing, enabled by default. After using one of the auth methods such as Universal Auth, the SDK will automatically renew and re-authenticate when needed. You can opt-out by settingAutoTokenRefresh to false in the client settings.
Client Lifecycle
When using automatic token refreshing it’s important to understand how your application uses the Infisical client. If you are instantiating new instances of the client often, it’s important to cancel the context when the client is no longer needed to avoid the token refreshing process from running indefinitely.Authentication
The SDK supports a variety of authentication methods. The most common authentication method is Universal Auth, which uses a client ID and client secret to authenticate.Universal Auth
Using environment variables Call.Auth().UniversalAuthLogin() with empty arguments to use the following environment variables:
INFISICAL_UNIVERSAL_AUTH_CLIENT_ID- Your machine identity client ID.INFISICAL_UNIVERSAL_AUTH_CLIENT_SECRET- Your machine identity client secret.
GCP ID Token Auth
Please note that this authentication method will only work if you’re running
your application on Google Cloud Platform. Please read
more about this authentication
method.
.Auth().GcpIdTokenAuthLogin() with empty arguments to use the following environment variables:
INFISICAL_GCP_AUTH_IDENTITY_ID- Your Infisical Machine Identity ID.
GCP IAM Auth
Using environment variables Call.Auth().GcpIamAuthLogin() with empty arguments to use the following environment variables:
INFISICAL_GCP_IAM_AUTH_IDENTITY_ID- Your Infisical Machine Identity ID.INFISICAL_GCP_IAM_SERVICE_ACCOUNT_KEY_FILE_PATH- The path to your GCP service account key file.
AWS IAM Auth
Please note that this authentication method will only work if you’re running
your application on AWS. Please read
more about this authentication
method.
.Auth().AwsIamAuthLogin() with empty arguments to use the following environment variables:
INFISICAL_AWS_IAM_AUTH_IDENTITY_ID- Your Infisical Machine Identity ID.
Azure Auth
Please note that this authentication method will only work if you’re running
your application on Azure. Please read
more about this authentication
method.
.Auth().AzureAuthLogin() with empty arguments to use the following environment variables:
INFISICAL_AZURE_AUTH_IDENTITY_ID- Your Infisical Machine Identity ID.
Kubernetes Auth
Please note that this authentication method will only work if you’re running
your application on Kubernetes. Please read
more about this
authentication method.
.Auth().KubernetesAuthLogin() with empty arguments to use the following environment variables:
INFISICAL_KUBERNETES_IDENTITY_ID- Your Infisical Machine Identity ID.INFISICAL_KUBERNETES_SERVICE_ACCOUNT_TOKEN_PATH_ENV_NAME- The environment variable name that contains the path to the service account token. This is optional and will default to/var/run/secrets/kubernetes.io/serviceaccount/token.
JWT Auth
Please note that this authentication method requires a valid JWT token from
your JWT issuer. Please read
more about this authentication
method.
LDAP Auth
Please note that this authentication method requires LDAP credentials. Please
read more about this
authentication method.
INFISICAL_LDAP_AUTH_IDENTITY_ID environment variable and pass empty string for the identity ID:
OCI Auth
Please note that this authentication method will only work if you’re running
your application on Oracle Cloud Infrastructure. Please read
more about this authentication
method.
INFISICAL_OCI_AUTH_IDENTITY_ID environment variable and omit the IdentityID field:
IdentityID(string) - Your Infisical Machine Identity ID. Can be set viaINFISICAL_OCI_AUTH_IDENTITY_IDenvironment variable.UserID(string) - Your OCI user OCID.TenancyID(string) - Your OCI tenancy OCID.Fingerprint(string) - Your OCI API key fingerprint.PrivateKey(string) - Your OCI private key (PEM format).Region(string) - Your OCI region (e.g.,us-ashburn-1).Passphrase(*string) - Optional: pointer to passphrase string if your private key is encrypted.
Organization Authentication
All SDK authentication methods support logging into a sub-organization that your machine identity has access to. This is optional and only necessary when attempting to authenticate into a sub-organization using an identity created at the root organization. Use the.Auth().WithOrganizationSlug("<organization-slug>") method to specify which organization to authenticate against:
If no organization slug is provided, the authentication session defaults to
the organization where the machine identity was originally created.
Secrets
List Secrets
client.Secrets().List(options)
Retrieve all secrets within the Infisical project and environment that client is connected to.
Parameters
object
Retrieve Secret
client.Secrets().Retrieve(options)
Retrieve a secret from Infisical. By default Secrets().Retrieve() fetches and returns a shared secret.
Parameters
object
Create Secret
client.Secrets().Create(options)
Create a new secret in Infisical.
Parameters
object
Update Secret
client.Secrets().Update(options)
Update an existing secret in Infisical.
Parameters
object
Delete Secret
client.Secrets().Delete(options)
Delete a secret in Infisical.
Parameters
object
Batch Create Secrets
client.Secrets().Batch().Create(options)
Create multiple secrets in Infisical.
Parameters
object
Folders
List Folders
client.Folders().List(options)
Retrieve all within the Infisical project and environment that client is connected to.
Parameters
object
Create Folder
client.Folders().Create(options)
Create a new folder in Infisical.
Parameters
object
Update Folder
client.Folders().Update(options)
Update an existing folder in Infisical.
Parameters
object
Delete Folder
client.Folders().Delete(options)
Delete a folder in Infisical.
Parameters
object
KMS
Create Key
client.Kms().Keys().Create(options)
Create a new key in Infisical.
Parameters
object
Return (object)
object
Delete Key
client.Kms().Keys().Delete(options)
Delete a key in Infisical.
Parameters
object
Return (object)
object
Signing Data
client.Kms().Signing().Sign(options)
Sign data in Infisical.
Parameters
object
Return ([]byte)
[]byte
The signature of the data that was signed.
Verifying Data
client.Kms().Signing().Verify(options)
Verify data in Infisical.
Parameters
object
Return (object)
object
List Signing Algorithms
client.Kms().Signing().ListSigningAlgorithms(options)
List signing algorithms in Infisical.
Parameters
object
Return ([]string)
[]string
The signing algorithms that are available for the key.
Get Public Key
This method is only available for keys with key usage
sign-verify. If you
attempt to use this method on a key that is intended for
encryption/decryption, it will return an error.client.Kms().Signing().GetPublicKey(options)
Get the public key in Infisical.
Parameters
object
Return (string)
string
The public key for the key.
Encrypt Data
client.Kms().Encryption().Encrypt(options)
Encrypt data with a key in Infisical KMS.
Parameters
object
Return (string)
string
The encrypted data.
Decrypt Data
client.Kms().DecryptData(options)
Decrypt data with a key in Infisical KMS.
Parameters
object
Return (string)
string
The decrypted data.