Skip to main content
Every call to Infisical goes through an InfisicalSDKClient. You create the client once, log it in as a machine identity, and then use it for every request.

Create a client

Create the client with the URL of your Infisical instance in host.
Parameters:
str
required
The URL of your Infisical instance.
str
An access token to send with every request. If you set it, you don’t need to log in.
int
default:"60"
The number of seconds to cache secrets for, or None to turn off the cache.
The client caches the secrets that get_secret_by_name and list_secrets return. Creating, updating, or deleting a secret through the client clears the cached secrets. The cache doesn’t see changes made anywhere else, so a secret can be up to cache_ttl seconds old. The cache keeps one copy of each secret, whatever version, view_secret_value, include_imports, or expand_secret_references you pass to get_secret_by_name. If you pass any of them, set cache_ttl to None. The cache runs a background thread. To stop the thread when you’re done with the client, call client.close(), or create the client in a with statement:

Log in

The client logs in with one of the machine identity’s authentication methods. After the client logs in, it sends the access token it got with every request.

Universal Auth

Parameters:
str
required
The client ID of the machine identity’s Universal Auth configuration.
str
required
A client secret of the machine identity’s Universal Auth configuration.

AWS auth

If your application runs on AWS, it can log in through AWS Auth with the AWS credentials it already has:
The SDK gets the details it needs from the AWS environment:
  • AWS credentials: the same way boto3 does, such as from environment variables or the IAM role of an EC2 instance or Lambda function
  • AWS region: from the AWS_REGION environment variable, or from the EC2 instance metadata if AWS_REGION isn’t set
Parameters:
str
required
The ID of the machine identity. If you pass None, the SDK uses the value of the INFISICAL_AWS_IAM_AUTH_IDENTITY_ID environment variable.

OIDC auth

If your identity provider issues OIDC tokens to your application, such as Okta or Auth0, the application can log in through OIDC Auth:
Parameters:
str
required
The ID of the machine identity.
str
required
The OIDC token from your identity provider.

LDAP auth

To log in with an LDAP username and password through LDAP Auth:
Parameters:
str
required
The ID of the machine identity.
str
required
The LDAP username.
str
required
The LDAP password.

Access token

If your application gets an access token some other way, such as through Token Auth, give the token to the client:
Parameters:
str
required
The access token, without the Bearer prefix.
To read the token that the client uses, call client.get_token().

Access token expiry

The SDK doesn’t renew the access token. The token expires after the Access Token TTL set in the machine identity’s auth method. If your application runs longer than that, log in again before the token expires. The login methods except token_auth.login return the token’s details, including its lifetime in seconds in expiresIn: