How to use the keyring.get_password function in keyring

To help you get started, we’ve selected a few keyring examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github spyder-ide / spyder / spyder / widgets / github / View on Github external
if username and remember_me and valid_py_os:
            # Get password from keyring
                password = keyring.get_password('github', username)
            except Exception:
                # No safe keyring backend
                if self._show_msgbox:
                                        _('Failed to retrieve password'),
                                        _('It was not possible to retrieve '
                                          'your password. Please introduce '
                                          'it again.'))
        if remember_token and valid_py_os:
            # Get token from keyring
                token = keyring.get_password('github', 'token')
            except Exception:
                # No safe keyring backend
                if self._show_msgbox:
                                        _('Failed to retrieve token'),
                                        _('It was not possible to retrieve '
                                          'your token. Please introduce it '

        if not running_under_pytest():
            credentials = DlgGitHubLogin.login(self.parent_widget, username,
                                            password, token, remember_me,

            if (credentials['username'] and credentials['password'] and
github nicksergeant / billmonster / View on Github external
except TimeoutException:
        WebDriverWait(b, timeout=10).until(_element_available(b, 'input#tlpvt-challenge-answer'))

    # If we have a password field now, fill it with the key and submit the form.
        password = b.find_element_by_css_selector('input#tlpvt-passcode-input')
    except NoSuchElementException:

        # We need to hit the keychain for the security question.
        answer = b.find_element_by_css_selector('input#tlpvt-challenge-answer')
        question = b.find_element_by_css_selector('label[for="tlpvt-challenge-answer"]').text.strip()

        # The keychain name should be "username What is your mother's middle name", for example.
        keyAnswer = keyring.get_password('', '{} {}'.format(user, question))

        # Make sure we have an answer for the question.
        if keyAnswer is None:
            puts("We couldn't find an answer for the question '{}' in your keyring's backend".format(question)))

        # Fill the answer and submit.

        # If we've answered correctly, now we have to wait for the password field.
        WebDriverWait(b, timeout=10).until(_element_available(b, 'input#tlpvt-passcode-input'))

        # Fill the password and submit.
        password = b.find_element_by_css_selector('input#tlpvt-passcode-input')
github matryer / bitbar-plugins / Lifestyle / View on Github external
def check_transmission(argv):
    remote_bin = '/usr/local/bin/transmission-remote' # also make this configurable ?
    host_ip = keyring.get_password("transmission-bitbar", "ip")
    host_port = keyring.get_password("transmission-bitbar", "port")
    host_user = keyring.get_password("transmission-bitbar", "username")
    host_pswd = keyring.get_password("transmission-bitbar", host_user)

    if 'slowdown' in argv:
        subprocess.check_output(remote_bin+' '+host_ip+':'+host_port+' --auth '+host_user+':'+host_pswd+' -as', shell=True)
    elif 'speedup' in argv:
        subprocess.check_output(remote_bin+' '+host_ip+':'+host_port+' --auth '+host_user+':'+host_pswd+' -AS', shell=True)
    elif 'pause' in argv:
        subprocess.check_output(remote_bin+' '+host_ip+':'+host_port+' --auth '+host_user+':'+host_pswd+' -t ' + argv[-1] + ' -S', shell=True)
    elif 'resume' in argv:
        subprocess.check_output(remote_bin+' '+host_ip+':'+host_port+' --auth '+host_user+':'+host_pswd+' -t ' + argv[-1] + ' -s', shell=True)

    session_info = subprocess.check_output(remote_bin+' '+host_ip+':'+host_port+' --auth '+host_user+':'+host_pswd+' -si -st', shell=True)
    session_info_lines = session_info.split('\n')
github microsoft / msticpy / msticpy / common / View on Github external
def _get_creds(self):
        if self.debug:
            print("Fetching creds from keyring")
            access_token = (
                keyring.get_password(self.keyring, "adal_context_1")
                + keyring.get_password(self.keyring, "adal_context_2")
                + keyring.get_password(self.keyring, "adal_context_3")
                + keyring.get_password(self.keyring, "adal_context_4")
            refresh_token = (
                keyring.get_password(self.keyring, "adal_context_5")
                + keyring.get_password(self.keyring, "adal_context_6")
                + keyring.get_password(self.keyring, "adal_context_7")
            expires_on = keyring.get_password(self.keyring, "adal_context_8")
            self.config_data = {
                "accessToken": access_token,
                "refreshToken": refresh_token,
                "expiresOn": expires_on,
        except (TypeError, KeyringError):
            if self.debug:
                print("No valid credentials in keyring %s" % self.keyring)
        if not self._is_valid_config_data():
            if self.debug:
                print("No valid authtoken config found in keyring")
github kootenpv / yagmail / yagmail / View on Github external
def _handle_password(self, password):
        """ Handles getting the password"""
        if password is None:
                password = keyring.get_password('yagmail', self.user)
            except NameError as e:
                print("'keyring' cannot be loaded. Try 'pip install keyring' or continue without. See")
                raise e
            if password is None:
                import getpass
                password = getpass.getpass(
                    'Password for <{0}>: '.format(self.user))
                answer = ''
                # Python 2 fix
                while answer != 'y' and answer != 'n':
                    prompt_string = 'Save username and password in keyring? [y/n]: '
                    # pylint: disable=undefined-variable
                        answer = raw_input(prompt_string).strip()
                    except NameError:
                        answer = input(prompt_string).strip()
github ipython / ipython / tools / View on Github external
def get_auth_token():
    global token

    if token is not None:
        return token

    import keyring
    token = keyring.get_password('github', fake_username)
    if token is not None:
        return token

    print("Please enter your github username and password. These are not "
          "stored, only used to get an oAuth token. You can revoke this at "
          "any time on Github.\n"
          "Username: ", file=sys.stderr, end='')
    user = input('')
    pw = getpass.getpass("Password: ", stream=sys.stderr)

    auth_request = {
      "scopes": [
      "note": "IPython tools %s" % socket.gethostname(),
github holgern / beem / beem / View on Github external
def unlock_wallet(stm, password=None):
    if stm.unsigned and stm.nobroadcast:
        return True
    password_storage = stm.config["password_storage"]
    if not password and KEYRING_AVAILABLE and password_storage == "keyring":
        password = keyring.get_password("beem", "wallet")
    if not password and password_storage == "environment" and "UNLOCK" in os.environ:
        password = os.environ.get("UNLOCK")
    if bool(password):
        password = click.prompt("Password to unlock wallet", confirmation_prompt=False, hide_input=True)

    if stm.wallet.locked():
        if password_storage == "keyring" or password_storage == "environment":
            print("Wallet could not be unlocked with %s!" % password_storage)
            password = click.prompt("Password to unlock wallet", confirmation_prompt=False, hide_input=True)
            if bool(password):
                unlock_wallet(stm, password=password)
                if not stm.wallet.locked():
                    return True
github mdrichardson / FUTpuppeteer / FUTpuppeteer / View on Github external
def __get_user_info__(self):
        if self.user.get('password', None) or not self.user['re-enter_user_settings']:
            # Get the info from OS credential manager
            ea_password = keyring.get_password('FUTpuppeteer_{}'.format(self.bot_number), 'ea_password')
            ea_secret = keyring.get_password('FUTpuppeteer_{}'.format(self.bot_number), 'ea_secret')
            imap_password = keyring.get_password('FUTpuppeteer_{}'.format(self.bot_number), 'imap_password')
            # Decrypt if they're encrypted
            if self.user['secure_passwords']:
                master_password = input('Enter Master Password: ')
                # We have to encode->unhexlify->decode because decrypt requires bytes and keyring uses string
                ea_password = decrypt(master_password, unhexlify(ea_password.encode())).decode('utf-8')
                ea_secret = decrypt(master_password, unhexlify(ea_secret.encode())).decode('utf-8')
                imap_password = decrypt(master_password, unhexlify(imap_password.encode())).decode('utf-8')
            # Store them in the Session Object so we can use them
            self.user['password'] = ea_password
            self.user['secret_answer'] = ea_secret
            self.user['imap_password'] = imap_password
github avsm / perscon / plugins / Keychain / View on Github external
def register_credential(svc, usr):
    pwd = keyring.get_password(svc, usr)
    uid = hashlib.sha1("%s" % (svc,)).hexdigest()
    data = { 'uid': uid, 'svc': svc, 'usr': usr, 'pwd': pwd, }
    print >>sys.stderr, "register_credential:", svc, usr, uid
    Perscon_utils.rpc("credential/%s" % (uid, ), data=sj.dumps(data, indent=2))