A python wrapper for onepassword cli version 2
Project description
OnePassword CLI v2 python wrapper
Quick n dirty python wrapper for the 1password cli version 2.
Setup
- Install the
op
cli by following these instructions. - Make sure you have
op
in your PATH and that it is not version 1
$ op --version
2.12.0
- Have your 1password username, password, and signin url handy
pip install onepassword2
or, for a local install
make local_install
Usage
CLI
The op
cli tool has a lot of options for managing multiple accounts, profiles, etc. Sessions opened with the cli terminate after 10 minutes, requiring the user to re-authenticate interactively. This is good security. However, if you need long running, non-interactive usage, it's a hindrance. onepassword2 comes with a handy CLI to automagify the signin process.
export OP_ACCOUNT='user@example.com'
export OP_PASSWORD="your password"
export OP_HOSTNAME="yourhost.1password.com"
eval $(op-signin)
...
$ op vault list
ID NAME
naaizerttzertzefzyhjroeqrq Private
In python scripts
username = "user@example.com"
password = "your password"
hostname = "yourhost.1password.com"
o = OP2( username, password, hostname)
o.signin()
for v in o.vaults():
print(v)
List items
for d in o.items():
print(d)
Get a single item as a python dictionary
item = o.item("my item")
print(item)
Get a single item as an OP2Item
object with handy methods to modify fields
item = o.item("my item", as_obj=True)
item.set("notesPlain", "new value for notes")
item.save()
TODO
A full list of the wrapped commands needs to be written.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for onepassword2-0.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae11bbee4f290e21f14efb1f8c7c0909472a55e81855a80c62b0371bc7965085 |
|
MD5 | d8ecca5551701d08bc19883cac6696b8 |
|
BLAKE2b-256 | d72a852e6f19811b8137ce6a9e945d483d9d8869af75858ab83cb137b805028d |