How to use the keyring.errors.KeyringError 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 python-poetry / poetry / tests / utils / test_helpers_keyring.py View on Github external
def set_password(self, servicename, username, password):
        raise KeyringError()
github python-poetry / poetry / tests / utils / test_helpers_keyring.py View on Github external
def delete_password(self, servicename, username):
        raise KeyringError()
github matrix-org / pantalaimon / pantalaimon / main.py View on Github external
glib_thread = None
        glib_fut = None
        pan_queue = None
        ui_queue = None
        message_router_task = None

    try:

        for server_conf in pan_conf.servers.values():
            proxy, runner, site = loop.run_until_complete(
                init(data_dir, server_conf, pan_queue, ui_queue)
            )
            servers.append((proxy, runner, site))
            proxies.append(proxy)

    except keyring.errors.KeyringError as e:
        context.fail(f"Error initializing keyring: {e}")

    async def wait_for_glib(glib_thread, fut):
        glib_thread.stop()
        await fut

    home = os.path.expanduser("~")
    os.chdir(home)

    def handler(signum, frame):
        raise KeyboardInterrupt

    signal.signal(signal.SIGTERM, handler)

    try:
        for proxy, _, site in servers:
github gkluoe / git2jss / git2jss / jss_keyring.py View on Github external
def store_creds_in_keychain(service, user, pwd):
    """ Attempt to store the JSS credentials in the keychain """
    try:
        keyring.set_password(service, user, pwd)
    except keyring.errors.KeyringError as error:
        print("Failed to store credentials in keychain: {}".format(error))
        print("If you are running in a virtualenv, this is expected")
        print("See: https://github.com/jaraco/keyring/issues/219")
        raise
github gkluoe / git2jss / git2jss / jss_keyring.py View on Github external
def get_creds_from_keychain(service, user):
    """" Fetch the credentials for `jss_url` from the keychain """
    try:
        result = keyring.get_password(service, user)
    except keyring.errors.KeyringError as error:
        print("Failed to get credentials from keychain: {}".format(error))
        print("If you are running in a virtualenv, this is expected")
        print("See: https://github.com/jaraco/keyring/issues/219")
        raise
    if result:
        return result
    else:
        raise keyring.errors.KeyringError(("Couldn't find a password in the keychain for\n"
                                           "%s on %s" % (user, service)))
github rianhunter / dbxfs / dbxfs / main.py View on Github external
ValueError) as e:
            print("Error using access token: %s" % (e,))
            access_token = None
            try_directly = True
        except OSError:
            if not yes_no_input("Error connecting to Dropbox, Try again?"):
                return 1
        else:
            break

    if save_access_token and yes_no_input("We're all connected. Do you want to save your credentials for future runs?", default_yes=True):
        keyring_user = ''.join([random.choice("asdfghjklzxcvbnmqwertyuiop")
                                for _ in range(24)])
        try:
            keyring.set_password(APP_NAME, keyring_user, access_token)
        except (KeyringError, RuntimeError) as e:
            print("We need a passphrase to encrypt your access token before we can save it.")
            print("Warning: Your access token passphrase must contain enough randomness to be resistent to hacking. You can read this for more info: https://blogs.dropbox.com/tech/2012/04/zxcvbn-realistic-password-strength-estimation/")
            while True:
                pass_ = getpass.getpass("Enter new access token passphrase: ")
                pass2_ = getpass.getpass("Enter new access token passphrase (again): ")
                if pass_ != pass2_:
                    print("Passphrases didn't match, please re-enter")
                else:
                    del pass2_
                    break
            config.pop('keyring_user', None)
            config['access_token_privy'] = privy.hide(access_token.encode('utf-8'), pass_, server=False)
            del pass_
            save_config = True
        else:
            config.pop('access_token_privy', None)
github microsoft / msticpy / msticpy / common / keyvault_client.py View on Github external
+ 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)
            self._get_token()
        if not self._is_valid_config_data():
            if self.debug:
                print("No valid authtoken config found in keyring")
            self._get_token()
github microsoft / msticpy / msticpy / common / secret_settings.py View on Github external
Parameters
        ----------
        secret_name : str
            Secret name.

        Returns
        -------
        Any
            Secret value.

        """
        if self.debug:
            print(f"Fetching {secret_name} from keyring")
        try:
            secret = keyring.get_password(self.keyring, secret_name)
        except (KeyringError, KeyringLocked):
            if self.debug:
                print(
                    "Keyring error retrieving credentials",
                    f"for {secret_name} from keyring {self.keyring}",
                )
        if not secret:
            if self.debug:
                print(
                    "No credentials", f"for {secret_name} from keyring {self.keyring}"
                )
        return secret