icloud-photos-downloader / icloud_photos_downloader

A command-line tool to download photos from iCloud
MIT License
6.85k stars 554 forks source link

[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 #492

Open blademainer opened 2 years ago

blademainer commented 2 years ago

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

jaysunneu commented 2 years ago

same error

hotlyq commented 2 years ago

Same happened to me and need help.

liangqiao2016 commented 2 years ago

same error, it seems wrong url "accountservice.p00.prod.me.com"

yangwawa commented 1 year ago
Two-step/two-factor authentication is required!
Traceback (most recent call last):
  File "/usr/bin/icloudpd", line 8, in <module>
    sys.exit(main())
  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/base.py", line 255, in main
    icloud = authenticate(
  File "/usr/lib/python3.10/site-packages/icloudpd/authentication.py", line 47, in authenticate
    request_2sa(icloud, logger)
  File "/usr/lib/python3.10/site-packages/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 'accountservice.p00.prod.me.com' after 6 queries
dn833 commented 1 year ago

anyone know how to fix this bug? o(╥﹏╥)o

MannyChen0507 commented 1 year ago

same error,and i can't resolve the url “accountservice.p00.prod.me.com”

Alex-Hou commented 1 year ago

This is not a bug. Maybe Apple already shutdown those APIs.

Linnnkkk commented 1 year ago

same error

kotori912 commented 1 year ago

same error

Arnold4869 commented 1 year ago

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

ghooost7 commented 1 year ago

Same error. It may be because Apple updated iCloud on the web.

Haoke98 commented 1 year ago

same error Is there a possibility? This is also because of the region. I think the service didn't wok properly for the requests from the china mainland.

Haoke98 commented 1 year ago

I have located the problem on the below and tried to request the API by the raw way .

截屏2022-12-03 00 18 42

After that I got the messege from that API on below:

截屏2022-12-03 00 30 46

{ "success": false, "error": "Missing X-APPLE-WEBAUTH-HSA-LOGIN cookie" } But I really don't know where can i get the cookie X-APPLE-WEBAUTH-HSA-LOGIN. Can anybody help me fix this or tell me where can i find it ?

Haoke98 commented 1 year ago

I had fixed this problem by the pyicloud . In another word, I had rewritten the icloudPD by using the new version of pyicloud. At the same time , I had implemented the two step authentication for the user for china mainland.

yunxiaofeng1001 commented 1 year ago

I had fixed this problem by the pyicloud . In another word, I had rewritten the icloudPD by using the new version of pyicloud. At the same time , I had implemented the two step authentication for the user for china mainland.

提个PR给仓库管理者? 我看你直接开了个新的仓库?

shiyipeng210 commented 1 year ago

I had tried to rewrite the icloudpd by using the new version of pyicloud.But I got an error:

2022-12-06 02:16:51 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 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/icloudpd-1.7.2-py3.10.egg/icloudpd/base.py", line 271, in main
    icloud = authenticate(
  File "/usr/lib/python3.10/site-packages/icloudpd-1.7.2-py3.10.egg/icloudpd/authentication.py", line 29, in authenticate
    icloud = pyicloud_ipd.PyiCloudService(
  File "/usr/lib/python3.10/site-packages/pyicloud/base.py", line 271, in __init__
    self.authenticate()
  File "/usr/lib/python3.10/site-packages/pyicloud/base.py", line 338, in authenticate
    self._webservices = self.data["webservices"]
KeyError: 'webservices'
2022-12-06 02:16:55 ERROR    2FA information missing from cookie. Authentication has failed
2022-12-06 02:16:55 ERROR     - Was the correct password entered?
2022-12-06 02:16:55 ERROR     - Was the 2FA code mistyped?
2022-12-06 02:16:55 ERROR     - Can you log into iCloud.com without receiving pop-up notifications?

And the value of self.data is {'domainToUse': 'iCloud.com.cn'} Can anybody help me fix this?

mbax2zf2 commented 1 year ago

Modified to use picklepete's pyicloud 1.0.0. 2FA expiration not handled. Use at your own risk.

Code goes here

shiyipeng210 commented 1 year ago

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 icloudpd file from your code in docker, but i got the same error

sensending commented 1 year ago

I meet the same issue, 2 ways for the issue

  1. change the apple id region from china to other country, then try again.
  2. someone has fixed the issue by adding the missing authentication, you can refer to https://github.com/Haoke98/icloud-killer
shiyipeng210 commented 1 year ago

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.

QiangGeCode commented 1 year ago

It works now, thanks a lot, man! Just one further question, what do you mean not handle the 2FA expiration? what will happen after 2FA expired? @mbax2zf2

QiangGeCode commented 1 year ago

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

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

  1. 用github上修改版目录/icloudpd下的三个文件,替代原版目录:/usr/local/lib/python3.8/dist-packages/icloudpd 下的三个同名文件:

    • authentication.py
    • download.py
    • base.py
  2. 安装pyicloud

    • sudo pip install pyicloud
  3. 安装完以后,修改文件:/usr/local/lib/python3.8/dist-packages/pyicloud/base.py,把文件中的icloud.com都替换成icloud.com.cn

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

nicolz commented 1 year ago

按你的步骤还是无法成功, 直接安装pyicloud和修改版就可以了, 不需要安装原版了:

  1. 如果安装了原版则先卸载: pip uninstall icloudpd
  2. pip install pyicloud
  3. 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"
  4. git clone https://github.com/mbax2zf2/icloud_photos_downloader.git
  5. cd icloud_photos_downloader && python setup.py build && python setup.py install
  6. 结束了,应该可以正常登录了
yong-lionheart commented 1 year ago

I am using the docker:pjoc/docker-icloudpd:master to fix the 2FA issue in China, so far I can create the key-ring, but after that I met below issue. Can you help me?

2023-01-14 18:06:42 INFO Check for new files using password stored in keyring file 2023-01-14 18:06:42 INFO Generating list of files in iCloud. This may take a long time if you have a large photo collection. Please be patient. Nothing is b eing downloaded at this time 2023-01-14 18:06:49 ERROR Failed check for new files files 2023-01-14 18:06:49 ERROR - Can you log into iCloud.com without receiving po p-up notifications? 2023-01-14 18:06:49 ERROR Error debugging info: 2023-01-14 18:06:49 ERROR Traceback (most recent call last): File "/usr/bin/icloudpd", line 33, in sys.exit(load_entry_point('icloudpd==1.7.2', 'console_scripts', 'icloudpd')( )) File "/usr/lib/python3.10/site-packages/click/core.py", line 1130, in call return self.main(args, kwargs) File "/usr/lib/python3.10/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/usr/lib/python3.10/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, ctx.params) File "/usr/lib/python3.10/site-packages/click/core.py", line 760, in invoke return __callback(args, kwargs) File "/usr/lib/python3.10/site-packages/icloudpd-1.7.2-py3.10.egg/icloudpd/bas e.py", line 563, in main download_photo(consecutive_files_found, item) File "/usr/lib/python3.10/site-packages/icloudpd-1.7.2-py3.10.egg/icloudpd/bas e.py", line 392, in download_photo date_path = folder_structure.format(created_date) KeyError: ' ' 2023-01-14 18:06:49 ERROR ** Please report problems here: https://github.c/ om/boredazfcuk/docker-icloudpd/issues

Failed check for new files files #261

5555yxy commented 1 year ago

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

AndreyNikiforov commented 1 year ago

Is the domain change the minimum required change or something else need to be changed too? #573

boredazfcuk commented 1 year ago

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.

AndreyNikiforov commented 1 year ago

Please try icloudpd docker >=1.9.0 and --domain cn parameter to solve the issue. If auth and/.or downloading still does not work, reopen the issue.

fuz2er commented 1 year ago
# icloudpd --version
icloudpd, version 1.9.0
# 
# 
# icloudpd --directory /path/to/data \
    --cookie-directory /path/to/cookies \
    --folder-structure {:%Y/%Y-%m-%d} \
    --username example@example.com \
    --domain cn
2023-02-13 00:00:34 DEBUG    Authenticating...
2023-02-13 00:00:39 INFO     Two-step/two-factor authentication is required!
Traceback (most recent call last):
  File "/bin/icloudpd", line 8, in <module>
    sys.exit(main())
  File "/usr/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3.8/site-packages/icloudpd/base.py", line 275, in main
    icloud = authenticator(domain)(
  File "/usr/lib/python3.8/site-packages/icloudpd/authentication.py", line 48, in authenticate_
    request_2sa(icloud, logger)
  File "/usr/lib/python3.8/site-packages/icloudpd/authentication.py", line 55, in request_2sa
    devices = icloud.trusted_devices
  File "/usr/lib/python3.8/site-packages/pyicloud_ipd/base.py", line 266, in trusted_devices
    request = self.session.get(
  File "/usr/lib/python3.8/site-packages/requests/sessions.py", line 600, in get
    return self.request("GET", url, **kwargs)
  File "/usr/lib/python3.8/site-packages/pyicloud_ipd/base.py", line 105, in request
    self._raise_error(code, reason)
  File "/usr/lib/python3.8/site-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
haogege commented 1 year ago

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 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

AndreyNikiforov commented 1 year ago

Looks like using .cn domain is not enough for iCloudPD to work from China. Reopening

derekhe commented 1 year ago

Same issue

zhpenn commented 1 year ago

same issue cn account

JiaY-shi commented 1 year ago

same issue

zhang24xiao commented 1 year ago

感觉这个bug不好解啊,好像挂了很久了~😅

AndreyNikiforov commented 1 year ago

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

best1000 commented 1 year ago

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

I tried the latest docker image pointing to an empty cookie folder and using '--doman cn'. But same 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

derekhe commented 1 year ago

Maybe guys you can try use this version: https://github.com/icloud-photos-downloader/icloud_photos_downloader/pull/608

droid-Q commented 1 year ago

Maybe guys you can try use this version: #608

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

wanghao14 commented 1 year ago

按你的步骤还是无法成功, 直接安装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. 结束了,应该可以正常登录了

@nicolz 感谢!完美解决!

jiaoting commented 1 year ago

1.14.0 same C:\Users\jiaoting\Downloads\下载暂存\icloudpd>icloud.exe --username jiaoting@126.com --delete-from-keyring --domain cn --outputfile Enter iCloud password for jiaoting@126.com: Save password in keyring? [y/N]: n Two-step authentication required. Your trusted devices are: Traceback (most recent call last): File "icloud.py", line 5, in File "pyicloud_ipd\cmdline.py", line 226, in main File "pyicloud_ipd\base.py", line 266, in trusted_devices File "requests\sessions.py", line 602, in get File "pyicloud_ipd\base.py", line 105, in request File "pyicloud_ipd\base.py", line 127, in _raise_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. [11904] Failed to execute script 'icloud' due to unhandled exception!

Coding-SYL commented 1 year ago

还没解决吗?