icloud_photos_downloader: Authentication failed because China mainland account migated to icloud.com.cn instead of icloud.com(with solution)

Hi,

Suddenly, this great tool stop working since 18/Nov, I didn’t touch anything on the server running it. I didn’t change my icloud password as well!

I installed it in Ubuntu, with Python 3.8.10. Anyone can help me? I really love this tool.

Error message are:

2021-11-20 15:02:31 DEBUG    Authenticating...
Traceback (most recent call last):
  File "/usr/local/bin/icloudpd", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/icloudpd/base.py", line 255, in main
    icloud = authenticate(
  File "/usr/local/lib/python3.8/dist-packages/icloudpd/authentication.py", line 29, in authenticate
    icloud = pyicloud_ipd.PyiCloudService(
  File "/usr/local/lib/python3.8/dist-packages/pyicloud_ipd/base.py", line 193, in __init__
    self.authenticate()
  File "/usr/local/lib/python3.8/dist-packages/pyicloud_ipd/base.py", line 219, in authenticate
    self.params.update({'dsid': resp['dsInfo']['dsid']})
KeyError: 'dsInfo'

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 7
  • Comments: 47 (1 by maintainers)

Most upvoted comments

update the file : site-packages/pyicloud_ipd/base.py

find the keywords icloud.com, there are only 2 lines, replace it with the icloud.com.cn. it should get back

150         self._home_endpoint = 'https://www.icloud.com.cn'
151         self._setup_endpoint = 'https://setup.icloud.com.cn/setup/ws/1'

For your info, the file need to be updated, the absolute path is: /usr/local/lib/python3.8/dist-packages/pyicloud_ipd/base.py

更新base.py为icloud.com.cn后,A账号可以同步了,但是B账号又不行了,同样都是中国的AB两个账号,一个是通过icloud.com完成验证,另一个却是通过icloud.com.cn验证,请问知道如何改成一样的吗? image

你用B账号从web登陆一次icloud.com以后应该就可以了

web登陆一次icloud.com也似乎不起作用,不会自动引导到icloud.com.cn去,而我手动通过icloud.com.cn登录账户,却会引导我去iCloud.com登录,就像发的图片那样,不然就无法进入。

我跟你一样的问题,两个账号怎么也弄不成一致的。没办法自己修改了一下base.py,判断当前apple_id是哪一个,替换设置不同的host。 我的解决了!!配置文件加一行就好!

–env icloud_china=True \

中国大陆 icloud 用户可以用这个

docker pull lewangdev/icloudpd:latest

我在 tag 为 1.7.2 原镜像基础上做了修改:

base.py

        self._home_endpoint = 'https://www.icloud.com'
        self._setup_endpoint = 'https://setup.icloud.com/setup/ws/1'

改为:

        self._home_endpoint = 'https://www.icloud.com.cn' if os.environ.get('icloud_china', '1') == '1' else 'https://www.icloud.com'
        self._setup_endpoint = 'https://setup.icloud.com.cn/setup/ws/1' if os.environ.get('icloud_china', '1') == '1' else 'https://setup.icloud.com/setup/ws/1'

然后使用以下 dockerfile 构建出新的镜像:

FROM icloudpd/icloudpd

COPY base.py /usr/lib/python3.8/site-packages/pyicloud_ipd/base.py

新镜像默认使用中国的域名,也可以通过传入环境变量禁止使用中国域名,如下:

--env icloud_china=0 \

update the file : site-packages/pyicloud_ipd/base.py

find the keywords icloud.com, there are only 2 lines, replace it with the icloud.com.cn. it should get back

150         self._home_endpoint = 'https://www.icloud.com.cn'
151         self._setup_endpoint = 'https://setup.icloud.com.cn/setup/ws/1'

Haha, great job!!

Actually, I just found those lines almost at the same time! now it’s working again!!

I might figure out the root cause, but no idea how to solve it.

Oringally, I set 2h interval for downloading. 16/Nov, I changed setting the crontab for every 1h to download the photo, which might cause too frequent access to icloud.

Then I just read a statement in icloudpd docker page:

Be careful if setting a short synchronisation period. Apple have a tendency to throttle connections that are hitting their server too often.

I guess, I set the interval too short, author recommend for 24h. Apple throttle my connections.

who knows how to solve the problem?

Currently, I disabled the crontab schedule downloading tasks, hope it will cooling down and re-enable the authentication.

你好,从19号早上6点多的计划任务开始也出现了相同的问题,我也有两个账号,和你一模一样,但我两个账号都是中国的,都设置6小时更新一次。目前A账号的计划任务完全正常可以正常同步,B账号就报和你一样的错误(AB两个账号当时都是同一天设置好的计划任务),可以判断应该就是账号的问题,或许正如你所说被限制了。我现在将B账号的计划任务停了,希望过几天能解除限制。如果找到解决办法大家可以同步一下,谢谢。