Skip to content

Instantly share code, notes, and snippets.

@jordanemedlock
Created September 19, 2017 16:27
Show Gist options
  • Save jordanemedlock/e75489704df9ae98c60fc0ef0d261287 to your computer and use it in GitHub Desktop.
Save jordanemedlock/e75489704df9ae98c60fc0ef0d261287 to your computer and use it in GitHub Desktop.
from pyicloud import PyiCloudService
import sys
import click
if __name__ == '__main__':
email = click.prompt('Email')
password = click.prompt('Password')
api = PyiCloudService(email, password)
if api.requires_2fa:
print("Two factor 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'))))
device = click.prompt('Which device would you like to use?', default=0)
device = devices[device]
if not api.send_verification_code(device):
print('Failed to send verification code')
sys.exit(1)
code = click.prompt('Please enter validation code')
if not api.validate_verification_code(device, code):
print('Failed to verify verification code')
sys.exit(1)
print(api.files.dir())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment