Not Working? #1

Jud opened this Issue Mar 30, 2013 · 3 comments

4 participants


I have this code:

import os
import sys
import getpass
import onepassword.keychain

# Our password function
def get_password(msg=False):
    # Get the password
    p = getpass.getpass(prompt='1Password: ', stream=sys.stderr)
    p = False if not len(p) else p

    return 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?

@Roguelazer Roguelazer was assigned Apr 22, 2013

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 [(['typeName'],['title']) for item in k.items]`

Ok, but how we can use data stored in k.items[1]._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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment