Commit graph

154 commits

Author SHA1 Message Date
Quentame
5efcbc2d2b
Fix response is not defined (#233) 2020-03-04 00:03:14 +01:00
Quentame
5368081b6b
Fix 450 error (#230)
- while refreshing client after 20 min of non request
2020-02-12 13:45:35 +01:00
Quentame
19a8079bc8
Use UTF-8 everywhere (#228) 2020-02-09 13:01:21 +01:00
Quentame
b20970098e Merge pull request #205 from ndbroadbent/patch-1
Fix PhotoAlbum#__str__ for UTF-8 album titles
2020-02-08 10:37:25 +01:00
Quentin POLLET
672a4ea2fe Fix tests 2020-02-05 20:37:14 +01:00
Emmanuel Ezeagwula
fc9b8faff9 fix Contacts services to return iphone contacts 2019-10-20 00:30:26 -07:00
Nathan Broadbent
01c8664aa6
Fix PhotoAlbum#__str__ for UTF-8 album titles
The __str__ method was crashing when an album title contained UTF-8 characters, such as an umlaut: "Jörg"
2019-05-10 15:28:23 +07:00
Adam Coddington
9bb6d75066
Merge pull request #184 from ndbroadbent/year_is_out_of_range
Fix 'ValueError: year is out of range' when year is set to 0000
2018-12-12 19:08:01 -08:00
Adam Coddington
c63e63bd82
Merge pull request #187 from ndbroadbent/override_client_id
Allow client_id to be overridden in __init__ (for replayable HTTP requests in pyvcr tests)
2018-12-12 19:07:02 -08:00
Nathan Broadbent
602ef0fbf5 Allow client_id to be overridden in __init__ (for replayable HTTP requests in pyvcr tests) 2018-07-31 01:16:56 +07:00
Nathan Broadbent
fa644415a4 Fix 'ValueError: year is out of range' when year is set to 0000. Just set the time to the earliest valid time (in 1970) 2018-07-22 03:34:35 +07:00
Maciej Buchert
b7401940c7
Update calendar.py 2018-05-20 17:27:38 +02:00
Maciej Buchert
3e912d8ccb
Update calendar.py 2018-05-20 17:22:50 +02:00
Maciej Buchert
abbe236812
Update calendar.py 2018-05-15 22:15:41 +02:00
Maciej Buchert
73dbbceb75
added new function
I added function that return calendars - names, guid, url and more
2018-05-15 21:37:12 +02:00
dillanmills
3899363167 Fixed a missed 2fa-2sa transition 2017-09-25 17:11:24 +02:00
Chad Johnson
4daf035689 Reimplement PhotosService to use the new ckdatabasews back-end (#137) 2017-09-24 15:22:17 +02:00
Ajay Gandhi
4ec58d7950 Add due date functionality for reminders (#105) 2017-09-24 14:58:59 +02:00
Tor Arne Vestbø
69af919ad5 Clarify that we support two-step, not two-factor, authentication
Two-step authentication is an older security method used for
accounts without an Apple device, or who are unable to upgrade
to iOS 9 or OS X El Capitan.

https://support.apple.com/en-us/HT204152

If the account has two-factor authentication enabled, we can still
fall back to the end-points for two-step authentication, as we do
not support 2FA yet.

Issue #102
2017-09-24 14:54:05 +02:00
Tor Arne Vestbø
be3d447c00 Handle HTTP errors before trying to parse JSON (#138) 2017-07-08 23:14:24 +02:00
Philip Lundrigan
bda08319fc photos: return time zone aware datetime object 2017-05-30 20:09:16 +02:00
Chad Johnson
200e00b37c Additional clientContext data for iphone play sound call - picklepete/pyicloud#90 2017-02-10 16:51:36 -06:00
Tor Arne Vestbø
ced8e83a40 Detect 'errorReason' in error messages from iCloud API 2017-01-09 19:39:40 +01:00
Tor Arne Vestbø
7d57f06bb1 Change PhotosAlbum._parse_binary_feed() to freestanding function
It doesn't really depend on self, and will be used from
outside PhotoAlbum.
2016-10-09 23:48:48 +02:00
Tor Arne Vestbø
2d541a9681 photos: Implement more generic folder fetching
Preparation for photo service update/refresh functionality.
2016-10-09 23:46:10 +02:00
Tor Arne Vestbø
1e53077ab9 Add basic logging to PhotosService 2016-10-09 23:40:11 +02:00
Tor Arne Vestbø
3b57397795 Add title and description properties to PhotoAsset 2016-10-09 23:39:16 +02:00
Tor Arne Vestbø
801ee8f7f7 Fix Python 3 issues in Photos service 2016-10-09 23:38:03 +02:00
Adam Coddington
1c80389305 Merge pull request #82 from satetsu888/master
fix reminder post function for python3
2016-06-20 20:40:36 -07:00
Adam Coddington
2b004a2a55 Minor alterations to AccountService. 2016-06-20 20:35:46 -07:00
serii
adb14d1468 Add ICloud Account service 2016-05-17 23:21:28 +03:00
shotaro.akiyama
e8d8f95afd Fix Reminder post function 2016-05-04 11:00:25 +09:00
Tor Arne Vestbø
358d84e334 Gracefully handle malformed cookiejars
LoadError would only be raised if the cookiejar didn't contain the
expected magic header. But a pickeled jar would potentially contain
data that raised a UnicodeDecodeError, so we need account for both.
2016-04-11 16:37:34 +02:00
Tor Arne Vestbø
721f2a0d69 Handle content-type header with parameters when debugging requests 2016-04-02 22:05:10 +02:00
Tor Arne Vestbø
1c1b9ef927 Detect TTY when deciding whether to enable interactive mode or not 2016-04-02 17:09:13 +02:00
Bart274
85598c9a6b Use Python 3 exception handling syntax (PEP 3110) 2016-03-13 15:07:25 +01:00
Bart274
a6aa998a04 Replace manual time zone handling with use of the tzlocal module
This solves an issue where we would end up with an empty list of
time zones, throwing an exception as a result.

It also resolves to the user's actual Olson time zone name,
instead of the first of all the possible time zone names that
match the current time zone of the user.

The two helper methods are no longer needed, as we can now use
get_localzone() directly.
2016-03-12 14:48:23 +01:00
Tor Arne Vestbø
8e45bf98db Don't set host header in reminders service
It's automatically taken care of by the requests module based on
the URL, and explicitly setting it on the globally shared session
object results in other services (such as the calendar service)
breaking when used after the reminders service in the same session.
2016-03-12 14:48:23 +01:00
Tor Arne Vestbø
b2f0cb992c Charge HTTP logging to separate child logger of each service
Unfortunately log filters only apply to each logger, not to its
children, so we have to make sure the http child loggers has the
same password filter as the root base filter.
2016-03-12 12:38:25 +01:00
Tor Arne Vestbø
c96a3bdc9f Don't assume request response is always JSON
If the response's content-type is not one of the two json mimetypes
iCloud will send us we need to return early, not try to parse the
error messsage out of an invalid json object.

For added safety we wrap the JSON decoding in a try/except, so that
malformed JSON data will not result in an exception from that part
of the code (though it will likely still raise at a later point when
the JSON data is parsed in service logic).

Fixes #71
2016-03-12 12:38:11 +01:00
Tor Arne Vestbø
8dc3f524ad Remove useless sanity check for sparse photo album assets
The length of a hash will always equal the length of its values.
2016-03-12 12:36:43 +01:00
Tor Arne Vestbø
9817d6b08a Remove leftover debug logging from iCloud Photo service 2016-03-12 12:36:43 +01:00
Tor Arne Vestbø
fa7ffa32f0 Tweak wording of password prompt
iCloud is branded with a lower case 'i' like most other Apple products.
2016-02-25 13:40:37 +01:00
Tor Arne Vestbø
58cbc51701 Add iCloud Photo Library service
Fixes issue #46.
2016-02-25 13:33:43 +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ø
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
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
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ø
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
ce8d570b21 Merge pull request #54 from torarnv/dont-regenerate-client-id
Don't generate clientId twice
2016-01-10 22:21:07 -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
kevin walchko
649d88316c fixed urllib3 https warning 2015-12-13 20:24:34 -08: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
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
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
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
Doug Hyde
830f08d6ed Fix calling the wrong function 2015-03-24 23:24:02 -07:00
Adam Coddington
e45984b49c Minor style changes. 2015-01-10 11:21:30 -08:00
Simon Elliston Ball
de51878a83 Enable family mode
refresh locations now includes all devices associated with your family,
not just the main account used.
2015-01-08 19:03:32 +00:00
Adam Coddington
77b17f091c Merge remote-tracking branch 'derphilipp/master' into python3k
Conflicts:
	pyicloud/cmdline.py
2014-10-25 20:34:27 -07:00
Adam Coddington
506d8e5ba3 Moving a docstring. 2014-10-06 06:32:33 -07:00
Adam Coddington
58cbec08f5 Properly send use only arguments following the first. 2014-10-05 21:10:01 -07:00
Adam Coddington
e5e961c6c1 Adding tox configuration; making sanity test Python 2.6 compatible. 2014-10-05 20:59:30 -07:00
Adam Coddington
622f38e4a6 Moving tests into the pyicloud package. 2014-10-05 20:48:00 -07:00
Adam Coddington
9c6e59c26d Adding a single basic test asserting that the help text is properly displayed. 2014-10-05 20:46:07 -07:00
Adam Coddington
434535f6a4 PEP8 compliance. 2014-10-05 20:38:17 -07:00
Adam Coddington
39965ce51a PEP8 compliance (line length). 2014-10-05 20:26:10 -07:00
Philipp Weissmann
c18fcf7221 Fixed python2.6 compatiblity, formating and spelling 2014-10-03 08:31:05 +02:00
Philipp Weissmann
cb5872c1a0 Use pytz instead of /etc/timezone; Python3 compatible 2014-10-02 10:55:33 +02:00
Philipp Weissmann
4f2e92c6e0 Python2 to Python3 conversion using 2to3 2014-10-02 09:52:26 +02:00
Adam Coddington
32bad85c75 Use absolute import for contacts module. Fixes #22. 2014-08-25 23:12:33 -07:00
Mario Mancino
4d4f3c31c7 added Contacts class 2014-08-22 18:42:44 +02:00
Mario Mancino
2623013b48 iCloud Contacts Support, based on pull-request from joachimneu 2014-08-22 18:36:06 +02:00
Benjamin Schollnick
1ca1a84648 Adding the command line wrapper, to allow shell script usage, and other applications to use pyicloud services. 2014-04-17 15:08:12 -07:00
Evgeny Tataurov
48d3432c9c Fix device indexing for python3 2014-01-26 13:25:07 +06:00
Peter Evans
16163f4ccb Adding a method for fetching a single event's details, which provides more information about an event, such as any notes ('description') about it. 2013-12-22 13:45:41 +00:00
Adam Coddington
3d87dac040 PEP-8 style fixes; removing missing imports; fixing ValueError when raising PyiCloudNoDevicesException 2013-10-11 18:34:13 -07:00
Adam Coddington
565146ac3d Encode to utf-8 before hashing. 2013-10-11 18:34:11 -07:00
Adam Coddington
af9f53eca6 Handling __str__ and __unicode__ in a Python2/3-agnostic manner. 2013-10-11 18:33:18 -07:00
Adam Coddington
b3cc67c01f Removing relative imports. 2013-10-11 18:33:18 -07:00
Adam Coddington
47f7c71b1b Should an instance key not be returned, generate a UUID instead. Fixes #9. 2013-10-11 18:10:19 -07:00
Benjamin Schollnick
405a603092 Added Display Message function, and password locking to Lost_Device
Added the ability to send a icloud message (with and without sound),
and password locking to Lost Device.
2013-05-31 10:26:30 -04:00
Adam Coddington
870d9bc7e9 Adding support for downloading files from iCloud's ubiquity service. 2013-05-18 22:35:52 -07:00