1pass-env
A focused CLI tool for importing environment variables from 1Password items. Quickly and securely import secrets from your 1Password vaults into environment files for your development workflow.
Features
- 🔐 Secure: Import secrets directly from 1Password using the official SDK
- 🚀 Simple: One command to import all your environment variables
- 🎯 Focused: Import exactly what you need with field filtering
- 📁 Smart: Automatically detects project names from folder structure
- 🔄 Safe: Confirms before overwriting existing files
Installation
pip install 1pass-env
Prerequisites
- Python 3.8 or higher
- 1Password service account token
Quick Start
-
Set up your 1Password service account token:
export OP_SERVICE_ACCOUNT_TOKEN="your-service-account-token"
-
Import all fields from a 1Password item:
1pass-env import --name my-app
-
Import specific fields only:
1pass-env import --name my-app --fields API_KEY,DATABASE_URL
-
Use with different vault and custom file:
1pass-env import --vault production-secrets --name my-app --file .env.prod
Command Reference
import
Import environment variables from an existing 1Password item.
1pass-env import [OPTIONS]
Options:
--vault, -v: 1Password vault name to import from (default: 'tokens')--name, -n: Item name in vault (default: current folder name)--fields, -f: Specific fields to import (comma-separated, e.g., API_KEY,SECRET_KEY)--file: Output file name (default: '1pass.env')--debug: Enable debug logging for detailed output
Examples:
# Import all fields from item 'my-app' in 'tokens' vault to '1pass.env'
1pass-env import --name my-app
# Import specific fields only
1pass-env import --name my-app --fields API_KEY,DB_PASSWORD
# Import to a custom file
1pass-env import --name my-app --file .env.production
# Use a different vault
1pass-env import --vault secrets --name my-app
# Enable debug mode to see all details
1pass-env import --name my-app --debug
# Use current folder name as item name (automatic detection)
cd my-awesome-project
1pass-env import # Looks for item named 'my-awesome-project'
How It Works
1pass-env connects to your 1Password vault using the official SDK and imports secrets into standard environment files:
- Authentication: Uses a service account token set via
OP_SERVICE_ACCOUNT_TOKEN - Smart defaults: Uses current folder name as item name if not specified
- Safe merging: Preserves existing variables when importing to existing files
- Field filtering: Import only the secrets you need for specific environments
Example Workflow
# Set up authentication
export OP_SERVICE_ACCOUNT_TOKEN="your-token-here"
# Import all development secrets
1pass-env import --vault dev-secrets --name my-project --file .env.dev
# Import only production API keys
1pass-env import --vault prod-secrets --name my-project --fields API_KEY,JWT_SECRET --file .env.prod
# Use the environment files
source .env.dev && npm start
# or with dotenv in your application
python -m dotenv -f .env.prod run python app.py
Generated File Format
# Environment variables imported from 1Password
# Vault: tokens
# Item: my-app
# Generated by 1pass-env
API_KEY="your-api-key-here"
DATABASE_URL="postgresql://user:pass@localhost/db"
JWT_SECRET="your-jwt-secret"
Configuration
Configure using environment variables:
OP_SERVICE_ACCOUNT_TOKEN: 1Password service account token (required)
Common Use Cases
Development Environment Setup
# Import shared development secrets
1pass-env import --vault dev-team --name shared-services
# Import project-specific secrets
1pass-env import --name my-project
# Override with local development values
echo "DEBUG=true" >> 1pass.env
echo "PORT=3001" >> 1pass.env
Multi-Environment Deployment
# Import environment-specific secrets
1pass-env import --vault dev-secrets --name myapp --file .env.development
1pass-env import --vault staging-secrets --name myapp --file .env.staging
1pass-env import --vault prod-secrets --name myapp --file .env.production
# Use with your deployment process
source .env.production && docker-compose up -d
Development
Setup
git clone https://github.com/himakarreddy/1pass-env.git
cd 1pass-env
pip install -e ".[dev]"
Testing
pytest
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- 1Password SDK for Python for secure secret management
- Click for the CLI framework
- Rich for beautiful terminal output
- python-dotenv for
.envfile handling
Metadata
Release files for 1pass-env 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| 1pass_env-0.1.0.tar.gz | 102.6 kB | Without provenance | Details for 1pass_env-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| 1pass_env-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for 1pass_env-0.1.0-py3-none-any.whl |
Total release size: 118.8 kB
Release files / 1pass_env-0.1.0.tar.gz
| Download URL | 1pass_env-0.1.0.tar.gz |
|---|---|
| Size | 102.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e8d05ae5153e198ad430a4c72d741752ef643da98210eab55103deb567180b2c
|
|
BLAKE2b-256 checksum How to use checksums |
bae62d460648e19db7328d727d505c0e30ebff72bdd78af52f3160f7800a3a09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.6
|
Release files / 1pass_env-0.1.0-py3-none-any.whl
| Download URL | 1pass_env-0.1.0-py3-none-any.whl |
|---|---|
| Size | 16.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
135e47988e30ac6ea7c73bed8011f8e178c9c317523d6eb17fa8287cc35e4525
|
|
BLAKE2b-256 checksum How to use checksums |
0408208e6c5e80f1458733823deaeaac86ce5f59a4c2f1f6a7117850293a5355
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.6
|
Security for 1pass-env 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.