I have this code:
# Our password function
# Get the password
p = getpass.getpass(prompt='1Password: ', stream=sys.stderr)
p = False if not len(p) else p
k = onepassword.keychain.AKeychain(
print k.decrypt(keyid=k.levels['SL5'], string="My Item")
When the string "My Item" is a 1Password "Account", it doesn't print anything. When the item is a 1password "Login" item, it prints out binary data. Have I set it up incorrectly?
Sorry for taking so long to respond to you.
You should be able to look through the items attribute of the AKeychain object. What do you get when you run the following:
print [(item.data['typeName'], item.data['title']) for item in k.items]`
Ok, but how we can use data stored in k.items._decrypted ? I need a password stored in encrypted section.
(I realize this is an almost year old issue, but I figured lost wandering souls could make use of my findings)
It is not completely obvious how onepasswordpy should be used without digging into the source code (something that one could improve upon in the README, perhaps?).
Here's a basic script that allows me to retrieve my 1password items using onepasswordpy. Of course you'll want to change the path on line 6 to your own setup (don't forget to switch AKeychain for CKeychain if your data resides in iCloud).
Additionally, on line 18, I'm using SL5. This should be fine for most cases, but if the script doesn't work with your keychain, that might be something to investigate.
If you're looking for more than what the very basic script offers, decrypted_data should hold most of what a typical user would be looking for.
Thanks again @Roguelazer for your work on this project; looking forward to adding some contributions in the future :)