Commit graph

269 commits

Author SHA1 Message Date
Tor Arne Vestbø
58cbc51701 Add iCloud Photo Library service
Fixes issue #46.
2016-02-25 13:33:43 +01:00
Tor Arne Vestbø
ab889e7232 Merge pull request #68 from torarnv/add-support-for-2fa
Add support for two-factor authentication (2FA)
2016-02-25 13:33:27 +01:00
Tor Arne Vestbø
7ec72a1625 Add support for two-factor authentication
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.
2016-02-25 13:33:05 +01:00
Tor Arne Vestbø
c3da6220ef Merge pull request #69 from torarnv/add-centralized-api-request-logging
Add centralized logging of iCloud API requests
2016-02-25 13:31:17 +01:00
Tor Arne Vestbø
acd4a2f7a4 Add centralized logging of iCloud API requests
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.
2016-02-25 13:26:11 +01:00
Adam Coddington
2f0dcd1ac2 [#64] Adds Keychain-based Authentication
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.
2016-02-23 17:44:03 -08:00
Adam Coddington
77978b391f Drops support for Python 2.6.
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.
2016-01-29 18:26:02 -08:00
Adam Coddington
13f71ddbcc Merge branch 'simplify-login-sequence' 2016-01-22 22:23:19 -08:00
Tor Arne Vestbø
fce7966974 Simplify login sequence
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.
2016-01-19 16:44:52 +01:00
Daren Lord
3b3857d295 Squashed commit of the following:
commit 211d54bb3f0e9fa942e31aa7d48b6cfbb22e126f
Author: Daren Lord <dlaccount@icloud.com>
Date:   Mon Jan 18 21:05:51 2016 -0700

    Fixed pep8 errors

commit 0a8ba6855405b39003f1aeef3b35fa4ef6a27e9e
Author: Daren Lord <dlaccount@icloud.com>
Date:   Mon Jan 18 21:02:02 2016 -0700

    Adding in six.

commit 1abff8f5cf5710d898a963b90be269b0127b1c96
Author: Daren Lord <dlaccount@icloud.com>
Date:   Mon Jan 18 20:57:31 2016 -0700

    Adding in python 3 support for cookielib
2016-01-19 07:22:29 -08:00
Adam Coddington
c0a597986e Merge pull request #57 from torarnv/various-cleanup-fixes
Various cleanup fixes
2016-01-19 07:11:05 -08:00
Adam Coddington
6b9926cfc2 Merge pull request #60 from torarnv/document-contacts-api
Document how to use the contacts API
2016-01-19 07:09:12 -08:00
Adam Coddington
e26202c93e Merge pull request #61 from yannickulrich/master
Adding Reminder support
2016-01-18 01:29:39 -08:00
yannickulrich
cb89d678cf PEP8 for base.py 2016-01-18 10:09:59 +01:00
yannickulrich
420c9a783c PEP8 compatibility 2016-01-18 09:38:14 +01:00
yannickulrich
9982477759 Adding Reminder support 2016-01-17 20:27:57 +01:00
Tor Arne Vestbø
a9ea0c28b4 Document how to use the contacts API 2016-01-14 00:07:06 +01:00
Tor Arne Vestbø
07aaaeb67a Fix reStructuredText inline literal formatting in README 2016-01-13 21:22:00 +01:00
Tor Arne Vestbø
5d241fd1b5 Don't set Host header manually
It's taken care of by the requests module, based on the url we're
posting to, so no need to juggle the host header ourselves.
2016-01-13 20:42:14 +01:00
Tor Arne Vestbø
35f7955228 Use same setup/login endpoint as iCloud webapp 2016-01-13 20:42:14 +01:00
Tor Arne Vestbø
2e836b9185 Remove three unused endpoint definitions from PyiCloudService base 2016-01-13 20:42:14 +01:00
Tor Arne Vestbø
603b1d8f57 Normalize HTTP header names to title case
The spec says they are case insensitive, so this is just for
consistency (with eg. Chrome).
2016-01-13 20:42:14 +01:00
Adam Coddington
604fe68414 Release 0.7.3; fixes for session handling to prevent e-mail notifications from being sent for each request. 2016-01-10 22:22:35 -08:00
Adam Coddington
ce8d570b21 Merge pull request #54 from torarnv/dont-regenerate-client-id
Don't generate clientId twice
2016-01-10 22:21:07 -08:00
Adam Coddington
176dc30a27 Merge pull request #55 from torarnv/rework-cookiejar-persistence-handling
Rework cookie persistence handling
2016-01-10 22:20:13 -08:00
Tor Arne Vestbø
733071a0f7 Rework cookie persistence handling
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.
2016-01-07 21:02:27 +01:00
Tor Arne Vestbø
5e41650d50 Don't generate clientId twice
We already generate and store the client ID in self.client_id, so
no need to re-generate it in refresh_validate().
2016-01-07 20:23:49 +01:00
Adam Coddington
d2bbf7dee5 Release 0.7.2; Validate certificate (and thus remove certificate validation warning). 2015-12-13 20:25:18 -08:00
Adam Coddington
3cf8b620ee Release 0.7.1; Validates Apple's server certificate (to eliminate an emitted warning). 2015-12-13 20:24:38 -08:00
kevin walchko
649d88316c fixed urllib3 https warning 2015-12-13 20:24:34 -08:00
Adam Coddington
9539a2c7d8 Adding 'certifi' to requirements list. 2015-12-13 20:23:45 -08:00
Adam Coddington
80f6cd6dec Merge pull request #53 from leres/master
Add optional verify parameter to allow verification of SSL certificates
2015-10-20 23:43:08 -07:00
Craig Leres
a532000d12 Add optional verify parameter to allow verification of SSL certificates
by the requests module.
2015-10-20 14:45:56 -07:00
Adam Coddington
f7f1cba66a Store only cookies having names beginning with X-APPLE-WEB-KB; cache copied request cookies as _cookies rather than mutable reference. 2015-05-24 14:49:59 -07:00
Adam Coddington
b0d3985a50 Release 0.7; adds functionality allowing us to store log-in cookies between sessions. 2015-05-17 23:16:36 -07:00
Adam Coddington
e849b5954e Merge branch 'patch-1'; Adds functionality which should limit the number of e-mail notices from Apple. 2015-05-17 23:15:23 -07:00
Adam Coddington
3d795fab1b Remove logging configuration. 2015-05-17 23:14:11 -07:00
Adam Coddington
d056c9b708 Updating cookie handling to serialize all cookies following the request. 2015-05-17 23:11:27 -07:00
Adam Coddington
67030b0eba Allow user to specify cookie directory. 2015-05-17 22:48:43 -07:00
Adam Coddington
1a3a2bd616 PEP-8 naming for 'newKBCookie.' 2015-05-13 22:01:05 -07:00
Adam Coddington
0419012e15 Make cookie loading a little more pythonic. 2015-05-13 22:00:47 -07:00
Adam Coddington
4daa34f310 Cleaning up cookie handling to use a system-level temporary directory. Adding logger. 2015-05-13 21:59:44 -07:00
Adam Coddington
c5dbfdd1df Updating readme. 2015-05-13 21:40:56 -07:00
Adam Coddington
e6d51f44d3 Merge pull request #42 from gitter-badger/gitter-badge
Add a Gitter chat badge to README.rst
2015-05-13 21:36:28 -07:00
The Gitter Badger
8d881d6691 Added Gitter badge 2015-05-14 04:35:47 +00:00
FiZiX
897f905855 Add X-APPLE-WEB-KB cookie handling
Add X-APPLE-WEB-KB cookie handling to prevent e-mail from Apple every time script is run.
2015-05-13 13:01:08 -04:00
Adam Coddington
7f7becb7d8 Changing permissions to something more appropriate. 2015-03-31 22:33:32 -07:00
Adam Coddington
52ecb52d6f Release 0.6.2; fixes timezone handling in calendar. 2015-03-25 21:16:35 -07:00
Adam Coddington
c1f2c924bb Merge pull request #38 from doughyde/master
Fix calling the wrong function
2015-03-25 21:15:42 -07:00
Adam Coddington
76a653664e Moving operator before line break. 2015-03-25 21:14:28 -07:00