How to use the pyicloud.utils.password_exists_in_keyring function in pyicloud

To help you get started, we’ve selected a few pyicloud 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 picklepete / pyicloud / pyicloud / cmdline.py View on Github external
if not password:
            password = utils.get_password(
                username,
                interactive=command_line.interactive
            )

        if not password:
            parser.error('No password supplied')

        try:
            api = pyicloud.PyiCloudService(
                username.strip(),
                password.strip()
            )
            if (
                not utils.password_exists_in_keyring(username) and
                command_line.interactive and
                confirm("Save password in keyring? ")
            ):
                utils.store_password_in_keyring(username, password)

            if api.requires_2sa:
                import click
                print("Two-step authentication required.",
                      "Your trusted devices are:")

                devices = api.trusted_devices
                for i, device in enumerate(devices):
                    print("  %s: %s" % (
                        i, device.get(
                            'deviceName',
                            "SMS to %s" % device.get('phoneNumber'))))