diff --git a/README.md b/README.md index 3d76803..2ffabaa 100644 --- a/README.md +++ b/README.md @@ -44,10 +44,18 @@ Run `icloud` program a first time to ensure everything is running smooth: ### Using 2FA -If you enabled 2FA on your Apple iCloud account, the script will run a simple -webserver and point you to the URL on localhost to pass it the 2FA code you -will get from one of your iDevices. This makes the script trustable for some -time and this operation is only required once in a while (every month or so). +If you enabled 2FA on your Apple iCloud account, you can request the 2FA code +beforehand by : +If your device is online: + Go to Settings > [your name]. + Tap Sign-In & Security > Two Factor Authentication. + Tap Get Verification Code +If your device is offline: + Go to Settings > [your name]. + Tap Sign-In & Security. + A message says "Account Details Unavailable." Tap Get Verification Code. +Put this 2FA code in the config.ini file, you have one minute to run the command line in the next section. + ## Usage diff --git a/config.example.ini b/config.example.ini index f23c82a..a28ebf5 100644 --- a/config.example.ini +++ b/config.example.ini @@ -1,13 +1,11 @@ [apple] email = apple_icloud_email password = apple_icloud_password +code_2fa = 2fa_code +iPhone_name = iPhone cookie_directory = COOKIE_DIRECTORY [nextcloud] server = https://cloud.example.com user = nextcloud_user password = nextcloud_password - -[webserver] -host = localhost -port = 8080 diff --git a/icloud_to_nextcloud.py b/icloud_to_nextcloud.py index 4ea94cf..ac7eb4b 100644 --- a/icloud_to_nextcloud.py +++ b/icloud_to_nextcloud.py @@ -4,78 +4,12 @@ import logging import sys import urllib.parse -import bottle import requests from pyicloud import PyiCloudService from requests.auth import HTTPBasicAuth -class StoppableCherootServer(bottle.ServerAdapter): - """ - We need a stoppable HTTP server, which can be stopped from within a route. - - This is not doable out of the box in bottle and is quite hacky using plain - WSGIRef. This is easier and cleaner with Cheroot (formally CherryPy) - backend. - """ - def run(self, handler): # pragma: no cover - from cheroot import wsgi - self.options['bind_addr'] = (self.host, self.port) - self.options['wsgi_app'] = handler - self.server = wsgi.Server(**self.options) - try: - self.server.start() - finally: - self.server.stop() - - -############################################ -# Web app to fetch 2FA code from the user. # -############################################ - -code_2fa = None # Global for passing 2FA code from web app to main script -app = bottle.Bottle() -server = None - - -@app.route('/') -def get_2fa(): - """ - Main HTTP route, display an HTML form to fetch 2FA code from user. - """ - return """ - - -
- -