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

The China region ID login shows an authentication error #819

Closed
randomatom opened this issue Apr 17, 2024 · 8 comments
Closed

The China region ID login shows an authentication error #819

randomatom opened this issue Apr 17, 2024 · 8 comments
Labels

Comments

@randomatom
Copy link

randomatom commented Apr 17, 2024

I am running the program in an Ubuntu 22.04 environment with Docker. Version: 1.17.4. The ID in the China region cannot be used normally, while the ID in the US region functions normally.

Overview

Steps to Reproduce

  1. run:
    Operating environment ubuntu 22.04
    Version:1.17.4
docker run -it --rm --name icloudpd \
  -v /mnt/nas/home/icloud/xxx:/data \
  -e TZ=CST-8  \
  -e auth_china=True \
  icloudpd/icloudpd:latest icloudpd  \
  --directory /data \
  --domain cn \
  --watch-with-interval 3600
  1. Enter Apple ID for the China region.
  2. The phone prompts for two-factor authentication.

Expected Behavior

Can log in.

Actual Behavior

2024-04-17 16:38:03 DEBUG    Authenticating...
iCloud Password:
2024-04-17 16:38:12 INFO     Two-step/two-factor authentication is required (2fa)
2024-04-17 16:38:13 ERROR    Authentication required for Account. (500)
Traceback (most recent call last):
  File "starters/icloudpd_ex.py", line 110, in <module>
  File "starters/icloudpd_ex.py", line 106, in main
  File "click/core.py", line 1157, in __call__
  File "click/core.py", line 1078, in main
  File "click/core.py", line 1688, in invoke
  File "click/core.py", line 1434, in invoke
  File "click/core.py", line 783, in invoke
  File "icloudpd/base.py", line 326, in main
  File "icloudpd/base.py", line 757, in core
  File "icloudpd/authentication.py", line 48, in authenticate_
  File "icloudpd/authentication.py", line 104, in request_2fa
  File "pyicloud_ipd/base.py", line 486, in trusted_devices
  File "requests/sessions.py", line 602, in get
  File "pyicloud_ipd/base.py", line 132, in request
  File "pyicloud_ipd/base.py", line 134, in request
  File "pyicloud_ipd/base.py", line 207, in _raise_error
pyicloud_ipd.exceptions.PyiCloudAPIResponseException: Authentication required for Account. (500)
[8] Failed to execute script 'icloudpd_ex' due to unhandled exception!

Context

Can log in normally with a US region Apple ID.

@randomatom randomatom added the bug label Apr 17, 2024
@AndreyNikiforov
Copy link
Collaborator

Did it work for 1.17.3 or earlier versions?

@randomatom
Copy link
Author

Using version 1.17.4 or latest does not work.

@randomatom
Copy link
Author

randomatom commented Apr 18, 2024

Version 1.17.3 can work

@betacat-ha
Copy link

The same problem exists with Apple ID in mainland China. The Apple ID in Taiwan is working properly.

Tested: 1.17.3 & 1.17.4 (Docker & macOS)

2024-04-27 08:46:12 DEBUG    Authenticating...
2024-04-27 08:46:13 ERROR    Authentication required for Account. (421)
Traceback (most recent call last):
  File "starters/icloudpd.py", line 6, in <module>
  File "click/core.py", line 1157, in __call__
  File "click/core.py", line 1078, in main
  File "click/core.py", line 1434, in invoke
  File "click/core.py", line 783, in invoke
  File "icloudpd/base.py", line 328, in main
  File "icloudpd/base.py", line 760, in core
  File "icloudpd/authentication.py", line 31, in authenticate_
  File "pyicloud_ipd/base.py", line 305, in __init__
  File "pyicloud_ipd/base.py", line 367, in authenticate
  File "pyicloud_ipd/base.py", line 399, in _authenticate_with_token
NameError: name 'PyiCloudConnectionException' is not defined. Did you mean: 'PyiCloudFailedLoginException'?
[6965] Failed to execute script 'icloudpd' due to unhandled exception!

@betacat-ha
Copy link

我发现这个函数在登录时返回了500错误,但是Web版的iCloud现在似乎没有检查信任设备的数量,还需要检查这个吗?

Translation: I noticed that this function is returning a 500 error when logging. Should we verify the count of trusted devices? It appears that iCloud Web isn't currently performing this check.

    def trusted_devices(self):
        """ Returns devices trusted for two-step authentication."""
        request = self.session.get(
            '%s/listDevices' % self.SETUP_ENDPOINT,
            params=self.params
        )
        return request.json().get('devices')

@AndreyNikiforov
Copy link
Collaborator

Translation: I noticed that this function is returning a 500 error when logging. Should we verify the count of trusted devices? It appears that iCloud Web isn't currently performing this check.

I also noticed that icloud.com Web access does not use listDevices call anymore, however that request works for icloudpd in US. IIUC that request does not work in China. One easy option I see is to make that request fail silently.

@AndreyNikiforov
Copy link
Collaborator

@betacat-ha pls check if 1.17.5 solves the issue with listDevices call from China.

@betacat-ha
Copy link

@betacat-ha pls check if 1.17.5 solves the issue with listDevices call from China.

Tested on macOS with no errors found. Thanks for your efforts!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants