icloud-photos-downloader / icloud_photos_downloader

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

Authorization for not 2fa account failed with error 'Missing apple_id field (Missing apple_id field)' #770

Open kumabon opened 10 months ago

kumabon commented 10 months ago

Overview

With an account without 2fa, running icloudpd-1.17.3-windows-amd64.exe fails with an error 'Missing apple_id field (Missing apple_id field)'. No such problem for accounts with 2fa.

Confirmed iCloud username/email + Password correct by logging in at appleid.apple.com

Steps to Reproduce

  1. Run \icloudpd-1.17.3-windows-amd64.exe --username <non 2fa account username> --password ***** --list-albums

Expected Behavior

Logs into icloud

Actual Behavior

Fails to login

iCloud username/email: <non 2fa account username>
2024-01-07 22:33:59 DEBUG    Authenticating...
iCloud Password:
2024-01-07 22:34:07 ERROR    Missing apple_id field (Missing apple_id field)
Traceback (most recent call last):
  File "pyicloud_ipd\base.py", line 387, in _authenticate_with_token
  File "requests\sessions.py", line 637, in post
  File "pyicloud_ipd\base.py", line 178, in request
  File "pyicloud_ipd\base.py", line 207, in _raise_error
pyicloud_ipd.exceptions.PyiCloudAPIResponseException: Missing apple_id field (Missing apple_id field)

The above exception was the direct cause of the following exception:

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 393, in _authenticate_with_token
pyicloud_ipd.exceptions.PyiCloudFailedLoginException: ('Invalid authentication token.', PyiCloudAPIResponseException('Missing apple_id field (Missing apple_id field)'))
[63796] Failed to execute script 'icloudpd' due to unhandled exception!

Context

Potentially related to issue #747

Also tried icloudpd-1.16.2-windows-amd64.exe but with different error 'Unknown reason'. 1.16.2 Last successful run on 3 Dec 2023, failed on 10 Dec 2023, did not try between those dates

iCloud username/email: <non 2fa account username>
2024-01-07 22:32:12 DEBUG    Authenticating...
iCloud Password:
2024-01-07 22:32:19 ERROR    Unknown reason
Traceback (most recent call last):
  File "pyicloud_ipd\base.py", line 220, in authenticate
  File "requests\sessions.py", line 637, in post
  File "pyicloud_ipd\base.py", line 105, in request
  File "pyicloud_ipd\base.py", line 127, in _raise_error
pyicloud_ipd.exceptions.PyiCloudAPIResponseError: Unknown reason

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "starters\icloudpd.py", line 5, 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 317, in main
  File "icloudpd\base.py", line 744, in core
  File "icloudpd\authentication.py", line 31, in authenticate_
  File "pyicloud_ipd\base.py", line 204, in __init__
  File "pyicloud_ipd\base.py", line 228, in authenticate
pyicloud_ipd.exceptions.PyiCloudFailedLoginException: ('Invalid email/password combination.', PyiCloudAPIResponseError('Unknown reason'))
[62252] Failed to execute script 'icloudpd' due to unhandled exception!
AndreyNikiforov commented 6 months ago

I cannot reproduce this error, since I have 2fa enabled for my accounts and new ones must have 2fa as well.

petarlaf commented 4 months ago

Same issue on my side, but with Docker install - latest version. I do have 2fa activated and etc. In fact, my phone pings me to confirm the login, but the error is already there.

docker run -it --rm --name icloudpd -v //OPENMEDIAVAULT/Personal/IOS_Photos:/data icloudpd/icloudpd:latest icloudpd --directory /data --username XXXXX@gmail.com --password XXXXX--watch-with-interval 3600 2024-07-20 12:17:31 DEBUG Authenticating... 2024-07-20 12:17:33 ERROR Missing apple_id field (Missing apple_id field) Traceback (most recent call last): File "pyicloud_ipd/base.py", line 241, in _authenticate_with_token File "requests/sessions.py", line 637, in post File "pyicloud_ipd/session.py", line 167, in request File "pyicloud_ipd/session.py", line 196, in _raise_error pyicloud_ipd.exceptions.PyiCloudAPIResponseException: Missing apple_id field (Missing apple_id field)

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "starters/icloudpd_ex.py", line 122, in File "starters/icloudpdex.py", line 118, 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 696, in main File "icloudpd/base.py", line 1130, in core File "icloudpd/authentication.py", line 53, in authenticate File "pyicloud_ipd/base.py", line 157, in init File "pyicloud_ipd/base.py", line 221, in authenticate File "pyicloud_ipd/base.py", line 247, in _authenticate_with_token pyicloud_ipd.exceptions.PyiCloudFailedLoginException: ('Invalid authentication token.', PyiCloudAPIResponseException('Missing apple_id field (Missing apple_id field)')) [8] Failed to execute script 'icloudpd_ex' due to unhandled exception!

CerisWhite commented 3 months ago

I can confirm this is an issue on my end as well. I do not have 2FA enabled and do not want to enable it whatsoever.

AndreyNikiforov commented 3 months ago

920 suggests that locked accounts (without 2fa) may cause "Missing apple_id field" errors. Unlocking from icloud.com helped.

CerisWhite commented 3 months ago

I was able to sign in just fine (I even had photos.icloud.com open while attempting to run the downloader).

petarlaf commented 3 months ago

I have 2FA, and the prompt comes up and I approve it, but the docker installer still fails.

petarlaf commented 3 months ago

Issue was that my Apple ID was locked for some reason... after unlocking it -it works fine.

Any chance you can add an appropriate error code?

stephenhouser commented 3 months ago

Same, Apple ID was mysteriously locked. Unlocking solved the problem.

tldr; My Apple ID/account was still available in all other contexts. There was no other indication or message that the account was locked. I was even able to login via Safari on macOS without issue. It was only when I logged in from a private Safari session that I got the account locked message. Following the bizarre process Apple has for unlocking that seems like you have to reset your password worked.

CerisWhite commented 3 months ago

The issue persists after attempting to reset my account password. As before, I can still log in fine on anything, and I still have an actual device signed in, indicating this is not an issue with the account being locked in any capacity.

If there is anything I need to retrieve from the server response to help diagnose the issue, please let me know.