omz / Pythonista-Issues

Issue tracker for Pythonista (iOS)
169 stars 14 forks source link

OnePasswordExtension integration #361

Open zrzka opened 7 years ago

zrzka commented 7 years ago

I've got lot of passwords in 1Password and I've got some scripts with login. And it's not so convenient to go to 1Password, unlock, copy the username, password, ... It would be nice if Pythonista can be bundled with OnePasswordExtension.

Integration is pretty simple:

To get a password, I do call something like this:

OnePasswordExtension.shared().findLogin(forURLString: Config.onePasswordUrl, for: self, sender: sender) {
    [weak self] loginDictionary, error in

    if let username = loginDictionary?["username"] as? String,
        let password = loginDictionary?["password"] as? String {
        self?.emailTextField.text = username
        self?.pinTextField.text = password
        self?.pinTextField.becomeFirstResponder()
    }
}

So there can be a simple wrapper / module named onepassword which can contain two functions.

def is_available():
    wraps OnePasswordExtension.shared().isAppExtensionAvailable()

def find_login(url, handler):
    wraps OnePasswordExtension.shared().findLogin(...)
    calls handler with login dictionary and error
m42e commented 6 years ago

:+1: