From 146dd0c7bb4795cc977e82b31d9f700c6ae485cd Mon Sep 17 00:00:00 2001 From: Matrix Dai Date: Sat, 3 Jun 2023 14:30:21 +0800 Subject: [PATCH 1/4] Support DOMAIN=cn env variable --- pyicloud/base.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pyicloud/base.py b/pyicloud/base.py index 6ac8bdbd..da5c3b28 100644 --- a/pyicloud/base.py +++ b/pyicloud/base.py @@ -1,4 +1,5 @@ """Library base file.""" +import os from uuid import uuid1 import inspect import json @@ -199,10 +200,14 @@ class PyiCloudService: pyicloud = PyiCloudService('username@apple.com', '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, From cfd6e38016b79c447e8a792aa0330f40269bb482 Mon Sep 17 00:00:00 2001 From: Matrix Dai Date: Sun, 4 Jun 2023 10:26:32 +0800 Subject: [PATCH 2/4] Update readme --- README.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.rst b/README.rst index 5d5b98fe..4850bb6e 100644 --- a/README.rst +++ b/README.rst @@ -67,6 +67,11 @@ If you would like to delete a password stored in your system keyring, you can cl $ icloud --username=jappleseed@apple.com --delete-from-keyring +Switch to icloud China 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) From a0fbc6421c8f27d17ee37999f752871468375597 Mon Sep 17 00:00:00 2001 From: Matrix Dai Date: Sun, 4 Jun 2023 10:27:41 +0800 Subject: [PATCH 3/4] Update readme --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index 4850bb6e..25185cb4 100644 --- a/README.rst +++ b/README.rst @@ -70,6 +70,7 @@ If you would like to delete a password stored in your system keyring, you can cl Switch to icloud China 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. From 7a59fb8ca4a42eaa5dfa7a6ed171fa2d75fcd92f Mon Sep 17 00:00:00 2001 From: Matrix Dai Date: Sun, 4 Jun 2023 10:29:06 +0800 Subject: [PATCH 4/4] Update readme --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 25185cb4..fa858e93 100644 --- a/README.rst +++ b/README.rst @@ -67,7 +67,7 @@ If you would like to delete a password stored in your system keyring, you can cl $ icloud --username=jappleseed@apple.com --delete-from-keyring -Switch to icloud China domain: +Switch to iCloud China mainland domain: .. code-block:: console