A Python script that fetches credentials from your Bitwarden vault and exposes them to Royal TSX as a Dynamic Credential Provider.
Credentials are read securely from macOS Keychain — no secrets are stored in the script or on disk.
- Royal TSX calls
bw-sync.pywhen it needs credentials - The script reads your Bitwarden API key and master password from macOS Keychain
- It logs in, unlocks, and syncs your Bitwarden vault via the Bitwarden CLI
- It outputs all vault items as a JSON object in the Royal TSX credential format
- Royal TSX maps those credentials to your connections automatically
- macOS
- Python 3
- Bitwarden CLI installed via Homebrew:
brew install bitwarden-cli
- A Bitwarden account with API key access (Personal API Key or Organization API Key)
- Royal TSX for Mac
- Log in to the Bitwarden Web Vault
- Go to Account Settings → Security → Keys → API Key
- Note your Client ID and Client Secret
Run the setup script — it will prompt for your credentials and store them securely in Keychain:
chmod +x setup-keychain.sh
./setup-keychain.shYou can verify the entries in Keychain Access.app by searching for bw-sync.
Open bw-sync.py and edit the configuration section at the top:
BW_PATH = "/opt/homebrew/bin/bw" # Path to the Bitwarden CLI binary
ORGANIZATION_IDS = [
"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", # Your Bitwarden Organization ID
]To find your Organization ID:
Bitwarden Web Vault → Organizations → your org → Settings → copy the Organization ID.
Remove the
--organizationidfilter inget_entries()if you want all personal vault items instead.
python3 bw-sync.pyExpected output:
- Log messages on stderr (login → unlock → sync → fetched N items)
- A JSON blob on stdout — this is what Royal TSX reads
- Open Royal TSX and edit your document
- Go to Credentials → add a Dynamic Credential
- Set the Script Interpreter to
python3 - Set the Script path to the full path of
bw-sync.py - Assign the dynamic credential to your connections
| Keychain Service | Keychain Account | Value |
|---|---|---|
BW_CLIENTID |
bw-sync |
Your Bitwarden Client ID |
BW_CLIENTSECRET |
bw-sync |
Your Bitwarden Client Secret |
BW_PASSWORD |
bw-sync |
Your Bitwarden Master Password |
| Bitwarden Type | Exported as |
|---|---|
| Login | Credential (username, password, URL) |
| Card | Credential with card fields as Custom Properties |
| Custom fields | Custom Properties (Text, Protected, YesNo) |
| Notes | Notes (HTML line breaks) |
| Multiple URIs | Primary URL + extra URLs as Custom Properties |
- Credentials are stored in macOS Keychain, never in the script or environment variables
- The script logs to stderr only — the JSON credential output on stdout is kept clean
- The Bitwarden CLI session is closed (
bw logout) after every run
MIT