Read 1Password Environments using 1Password SDKs Beta
You can use 1Password SDKs to programatically read environment variables stored in 1Password Environments (beta) and use them in your applications.
Requirements
To use this feature, you'll need to install the beta version of the Go, JS, or Python SDK:
- Go
- JavaScript
- Python
Read environment variables
- Go
- JavaScript
- Python
To read environment variables stored in an Environment, use the GetVariables() method. Replace <your-environment-id> with the Environment's ID.
To read environment variables stored in an Environment, use the getVariables() method. Replace <your-environment-id> with the Environment's ID.
To read environment variables stored in an Environment, use the get_variables() method. Replace <your-environment-id> with the Environment's ID.
The method returns a GetVariablesResponse object that contains a list of the environment variables stored in the Environment.
- Go
- JavaScript
- Python
Each environment variable in the response contains the following:
- Name: The environment variable's name (for example,
DB_HOST). - Value: The environment variable's value.
- Masked: A boolean that indicates whether the value is hidden by default in the 1Password app.
- Go
- JavaScript
- Python
1Password Environment variables are masked by default. To change this:
- Open and unlock the 1Password desktop app.
- Select Developer > View Environments.
- Choose the Environment, select Edit, then select the vertical ellipsis next to the variable and select Show value by default.
Appendix: Get an Environment's ID
To read environment variables from a 1Password Environment, you'll need its unique identifier (ID). You can find this ID in the 1Password desktop app:
- Open and unlock the 1Password desktop app.
- Navigate to Developer > View Environments.
- Select View environment next to the Environment you want to fetch.
- Select Manage environment > Copy environment ID.