When 2FA is enabled in iCloud most iCloud services are unavailable
without first going through the 2FA handshake. We now have API to
initiate the 2FA, which can be used by more advanced API clients.
The built in command line 'icloud' application has not been updated,
as listing and managing devices though Find my iPhone is one of the
services that do not require 2FA.
Fixes issue #66.
Allows easier debugging of failing API calls. We filter out iCloud
password so that debug logs can be attached to bug reports, etc.
Errors are raised as PyiCloudAPIResponseError with a reason and
code property, in addition to being logged, which allows them to
be handled by client code, or will at least give a clearer idea
about the issue than e.g. opaque key errors when trying to access
non existent properties of the JSON response.
Squashed commit of the following:
commit 0eb23aa87c264152716933e03827f040742e6d70
Author: Adam Coddington <me@adamcoddington.net>
Date: Sat Feb 20 14:21:48 2016 -0800
Updating readme to reflect updated flow.
commit 840268e2db6093b5cb573c6a3e71204bf5b08b48
Author: Adam Coddington <me@adamcoddington.net>
Date: Sat Feb 20 14:18:39 2016 -0800
Dropping python 2.6 support workaround.
commit 9dcbd460482c2925bda490be2be884a2a2526062
Author: Adam Coddington <me@adamcoddington.net>
Date: Sat Feb 20 14:18:00 2016 -0800
Adding additional behavior at @torarnv's request.
commit 6c711bb12beea7c792b5d386203373423b6e56e2
Author: Adam Coddington <me@adamcoddington.net>
Date: Sat Jan 23 15:08:29 2016 -0800
Workaround for obsolete versions of Python 2.
commit b0765b7b6bf9974348061043da9a110c6bd7d985
Author: Adam Coddington <me@adamcoddington.net>
Date: Sat Jan 23 14:56:53 2016 -0800
Style changes to avoid line length overage.
commit 4decc576432ef23edae01b9621f2689b4f3c6c84
Author: Adam Coddington <me@adamcoddington.net>
Date: Sat Jan 23 14:01:27 2016 -0800
Adding documentation; also adding --delete-from-keyring command-line option.
commit a6b0224e93a8bc9159cf06ba5792a384f7fbb060
Author: Adam Coddington <me@adamcoddington.net>
Date: Sat Jan 23 13:44:09 2016 -0800
Adding functionality allowing authentication using iCloud passwords stored in the system keychain.
Adds the following new command-line options:
* `--password-interactive`: Allows you to specify your password
interactively rather than typing it into the command-line.
* `--store-in-keychain`: Allows you to store the password in use in the
system keychain.
If no password is specified when instantiating `PyiCloudService` or when
using the command-line utility (via either `--password-interactive` or
`--password`), the system keychain will be queried for a stored
password, and an exception will be raised if one was not found.
commit 4ba03fb02d51673dfb7183dde49ab4c0bec4afb3
Author: Adam Coddington <me@adamcoddington.net>
Date: Sat Jan 23 13:43:39 2016 -0800
Removing unused imports.
Squashed commit of the following:
commit 2f3bc6d4829c0f6f901ed2185a2e05f31d1be79f
Author: Adam Coddington <me@adamcoddington.net>
Date: Sat Jan 23 14:58:44 2016 -0800
Most modern tools have dropped support for Python 2.6 at this point; we should, too.
There's no need to validate before authenticating, as we don't log
in with extended_login=True, which means there are no persisted
login cookies besides the one ensuring we only get a single e-mail.
The id that refresh_validate used to generate is also not needed,
as authentication with just the username and password works fine,
and is what the icloud.com webapp also does.
Finally, we can skip the second validate after authentication as
the dsInfo/dsid is available through the response we get from the
authentication.
Instead of trying to look for a specific cookie to save, discarding all
others, and persisting the cookies manually using pickle, we build on
the functionality of cookielib, which already has functionality to save
and load cookiejars. The request library is documented to work with any
subclass of cookielib.CookieJar.
This ensures that we only save persistent cookies (which includes the
X-APPLE-WEB-KB cookie), and skip session cookies, which should make the
code more future proof in case Apple adds more persistent cookies.
This also fixes#44, which was still occurring because we were
persisting the cookies of the request, not the session, and when
logging in with a persisted cookie the resulting request did not
have the X-APPLE-WEB-KB set, so we ended up overwriting the cookie
file with one that didn't contain any X-APPLE-WEB-KB cookie anymore.