icloud_photos_downloader: [China] A error happened when login to icloud: pyicloud_ipd.exceptions.PyiCloudAPIResponseError: statusCode = UnknownServerError, IOException sending request https://accountservice.p00.prod.me.com:443/api/get_challenge_devices, Failed to resolve 'accountservice.p00.prod.me.com' after 6 queries

Overview

Trace info:

2022-11-04 23:00:52 INFO     Using password stored in keyring file: /config/python_keyring/keyring_pass.cfg                                                                                                 
2022-11-04 23:00:52 INFO     Correct owner on config directory, if required                                                                                                                                 
2022-11-04 23:00:52 INFO     Correct group on config directory, if required                                                                                                                                 
2022-11-04 23:00:52 INFO     Generate 2FA cookie using password stored in keyring file                                                                                                                      
Traceback (most recent call last):                                                                                                                                                                          
  File "/usr/bin/icloudpd", line 33, in <module>                                                                                                                                                            
    sys.exit(load_entry_point('icloudpd==1.7.2', 'console_scripts', 'icloudpd')())                                                                                                                          
  File "/usr/lib/python3.10/site-packages/click/core.py", line 722, in __call__                                                                                                                             
    return self.main(*args, **kwargs)                                                                                                                                                                       
  File "/usr/lib/python3.10/site-packages/click/core.py", line 697, in main                                                                                                                                 
    rv = self.invoke(ctx)                                                                                                                                                                                   
  File "/usr/lib/python3.10/site-packages/click/core.py", line 895, in invoke                                                                                                                               
    return ctx.invoke(self.callback, **ctx.params)                                                                                                                                                          
  File "/usr/lib/python3.10/site-packages/click/core.py", line 535, in invoke                                                                                                                               
    return callback(*args, **kwargs)                                                                                                                                                                        
  File "/usr/lib/python3.10/site-packages/icloudpd-1.7.2-py3.10.egg/icloudpd/base.py", line 255, in main                                                                                                    
    icloud = authenticate(                                                                                                                                                                                  
  File "/usr/lib/python3.10/site-packages/icloudpd-1.7.2-py3.10.egg/icloudpd/authentication.py", line 47, in authenticate                                                                                   
    request_2sa(icloud, logger)                                                                                                                                                                             
  File "/usr/lib/python3.10/site-packages/icloudpd-1.7.2-py3.10.egg/icloudpd/authentication.py", line 53, in request_2sa                                                                                    
    devices = icloud.trusted_devices                                                                                                                                                                        
  File "/usr/lib/python3.10/site-packages/pyicloud_ipd/base.py", line 249, in trusted_devices                                                                                                               
    request = self.session.get(                                                                                                                                                                             
  File "/usr/lib/python3.10/site-packages/requests/sessions.py", line 600, in get                                                                                                                           
    return self.request("GET", url, **kwargs)                                                                                                                                                               
  File "/usr/lib/python3.10/site-packages/pyicloud_ipd/base.py", line 100, in request                                                                                                                       
    self._raise_error(code, reason)                                                                                                                                                                         
  File "/usr/lib/python3.10/site-packages/pyicloud_ipd/base.py", line 122, in _raise_error                                                                                                                  
    raise api_error                                                                                                                                                                                         
pyicloud_ipd.exceptions.PyiCloudAPIResponseError: statusCode = UnknownServerError, IOException sending request https://accountservice.p00.prod.me.com:443/api/get_challenge_devices, Failed to resolve 'acco
untservice.p00.prod.me.com' after 6 queries                                                                                                                                                                 
2022-11-04 23:00:59 ERROR    2FA information missing from cookie. Authentication has failed                                                                                                                 
2022-11-04 23:00:59 ERROR     - Was the correct password entered?                                                                                                                                           
2022-11-04 23:00:59 ERROR     - Was the 2FA code mistyped?                                                                                                                                                  
2022-11-04 23:00:59 ERROR     - Can you log into iCloud.com without receiving pop-up notifications?

It seems the domain accountservice.p00.prod.me.com is removed from apple.

ref to: https://github.com/boredazfcuk/docker-icloudpd/issues/227

Steps to Reproduce

  1. /usr/bin/icloudpd --username “${0}” --cookie-directory “${1}” --directory “${2}” --only-print-filenames --recent 0’ – “${apple_id}” “${config_dir}”
  2. type the password

Expected Behavior

Actual Behavior

Context

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 42 (1 by maintainers)

Most upvoted comments

same error

按你的步骤还是无法成功, 直接安装pyicloud和修改版就可以了, 不需要安装原版了: 0. 如果安装了原版则先卸载: pip uninstall icloudpd

  1. pip install pyicloud
  2. sed -i
    -e “s#icloud.com/#icloud.com.cn/#”
    -e “s#icloud.com"#icloud.com.cn"#”
    “$(pip show pyicloud | grep “Location” | awk ‘{print $2}’)/pyicloud/base.py”
  3. git clone https://github.com/mbax2zf2/icloud_photos_downloader.git
  4. cd icloud_photos_downloader && python setup.py build && python setup.py install
  5. 结束了,应该可以正常登录了

我来分享一下我怎么做的:

如何在安装了原版的基础上更新成修改版:

  1. 用github上修改版目录/icloudpd下的三个文件,替代原版目录:/usr/local/lib/python3.8/dist-packages/icloudpd 下的三个同名文件:
  • authentication.py
  • download.py
  • base.py
  1. 安装pyicloud
  • sudo pip install pyicloud
  1. 安装完以后,修改文件:/usr/local/lib/python3.8/dist-packages/pyicloud/base.py,把文件中的icloud.com都替换成icloud.com.cn

  2. 结束了,应该可以恢复备份了

Modified to use picklepete’s pyicloud 1.0.0. 2FA expiration not handled. Use at your own risk. Code goes here

I had tried to replace the pyicloud file from your code in docker, but i got the same error

ok i have solved this problem., just replace icloud.com by icloud.com.cn in file /pyicloud/base.py(pyicloud1.0.0). or use this shell below in Linux

sed -i \
         -e "s#icloud.com/#icloud.com.cn/#" \
         -e "s#icloud.com\"#icloud.com.cn\"#" \
         "$(pip show pyicloud | grep "Location" | awk '{print $2}')/pyicloud/base.py"

And my downloader can work.

version 1.9.0,Error still exists

Two-step authentication required. Your trusted devices are: Traceback (most recent call last): File “/usr/local/bin/icloud”, line 8, in <module> sys.exit(main()) File “/usr/local/lib/python3.7/dist-packages/pyicloud_ipd/cmdline.py”, line 226, in main devices = api.trusted_devices File “/usr/local/lib/python3.7/dist-packages/pyicloud_ipd/base.py”, line 268, in trusted_devices params=self.params File “/usr/local/lib/python3.7/dist-packages/requests-2.28.2-py3.7.egg/requests/sessions.py”, line 600, in get return self.request(“GET”, url, **kwargs) File “/usr/local/lib/python3.7/dist-packages/pyicloud_ipd/base.py”, line 105, in request self._raise_error(code, reason) File “/usr/local/lib/python3.7/dist-packages/pyicloud_ipd/base.py”, line 127, in _raise_error raise api_error pyicloud_ipd.exceptions.PyiCloudAPIResponseError: statusCode = UnknownServerError, IOException sending request https://accountservice.p00.prod.me.com:443/api/get_challenge_devices, accountservice.p00.prod.me.com

有谁还在研究这个bug吗,我的验证到期几天了,一直没办法再次验证成功

Maybe guys you can try use this version: #608

It is working! CleanShot 2023-03-18 at 11 43 48@2x

Folks, Can somebody try binary icloudpd pointing to a new cookie folder and using --domain cn parameter, please? My theory is that “accountservice.p00.prod.me.com” url is saved in the session state from calls to icloud.com prior to using “cn” domain. If new cookie folder is used with --domain cn parameter, then initial authentication will save session data together with url to service that is available in China. TIA

Hi Andrey. Thanks for all your work on this recently. I can see a great deal of effort has gone into it over the past few weeks.

Someone submitted a PR to my container to ‘fix’ this issue, PR is here: https://github.com/boredazfcuk/docker-icloudpd/pull/265/commits/d0ffe24212cea558a3b9eead8f2d413c62b170f3

It is using a custom pyicloud so I believe there is more to it than just changing the domain. Some users claim that it no longer downloads Live Photos after that change though.

You might want to take a look at it anyway.

我win11环境可以了,总结一下就是用picklepete/pyicloudmbax2zf2/icloud_photos_downloader,然后pyicloud里的base.py要替换.cn 就可以正常下载图片视频,可以完成双重认证。不知主分支何时更改

Same happened to me and need help.