Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple alternative to support iCloud China mainland domain #428

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ If you would like to delete a password stored in your system keyring, you can cl

$ icloud [email protected] --delete-from-keyring

Switch to iCloud China mainland domain:

.. code-block:: console

export DOMAIN=cn

**Note**: Authentication will expire after an interval set by Apple, at which point you will have to re-authenticate. This interval is currently two months.

Two-step and two-factor authentication (2SA/2FA)
Expand Down
13 changes: 9 additions & 4 deletions pyicloud/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Library base file."""
import os
from uuid import uuid1
import inspect
import json
Expand Down Expand Up @@ -199,10 +200,14 @@ class PyiCloudService:
pyicloud = PyiCloudService('[email protected]', 'password')
pyicloud.iphone.location()
"""

AUTH_ENDPOINT = "https://idmsa.apple.com/appleauth/auth"
HOME_ENDPOINT = "https://www.icloud.com"
SETUP_ENDPOINT = "https://setup.icloud.com/setup/ws/1"
if os.environ.get("DOMAIN", "") == "cn":
AUTH_ENDPOINT = "https://idmsa.apple.com.cn/appleauth/auth"
HOME_ENDPOINT = "https://www.icloud.com.cn"
SETUP_ENDPOINT = "https://setup.icloud.com.cn/setup/ws/1"
else:
AUTH_ENDPOINT = "https://idmsa.apple.com/appleauth/auth"
HOME_ENDPOINT = "https://www.icloud.com"
SETUP_ENDPOINT = "https://setup.icloud.com/setup/ws/1"

def __init__(
self,
Expand Down