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

icloudpd fails to authenticate to iCloud (iCloud Picture Downloader) #994

Closed
LarsPoulsen opened this issue Nov 9, 2024 · 17 comments
Closed
Labels

Comments

@LarsPoulsen
Copy link

Overview

Trying to download most recent picture from my iCloud camera roll, using command line
icloudpd -u [email protected] -p myPassWord! --recent 1 --folder-structure {:%Y/%m} --directory /pictures/Imports/username
on Fedora 40

Steps to Reproduce

See above

Expected Behavior

Expect to see one picture get downloaded

Actual Behavior

icloudpd -u [email protected] -p myPassWord! --recent 1 --folder-structure {:%Y/%m} --directory /pictures/Imports/Lars
2024-11-09 12:54:34 DEBUG Authenticating...
2024-11-09 12:54:35 ERROR Service Temporarily Unavailable (503)
Traceback (most recent call last):
File "pyicloud_ipd/base.py", line 357, in authenticate
File "requests/sessions.py", line 637, in post
File "pyicloud_ipd/base.py", line 134, in request
File "pyicloud_ipd/base.py", line 207, in _raise_error
pyicloud_ipd.exceptions.PyiCloudAPIResponseException: Service Temporarily Unavailable (503)

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

Traceback (most recent call last):
File "starters/icloudpd.py", line 6, in
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 365, in authenticate
pyicloud_ipd.exceptions.PyiCloudFailedLoginException: ('Invalid email/password combination.', PyiCloudAPIResponseException('Service Temporarily Unavailable (503)'))
[777119] Failed to execute script 'icloudpd' due to unhandled exception!

Context

This has worked recently. No significant updates recently (other than the incremental dnf updates that run daily).
Not cured by retries.
Not cured by removing folder ~/.pyicloud and its contents.
My iPhone did not get the 2FA prompts.

@LarsPoulsen LarsPoulsen added the bug label Nov 9, 2024
@petarlaf
Copy link

petarlaf commented Nov 9, 2024

I have the same issue since a few weeks ago:

icloudpd-1.23.4-windows-amd64.exe --username [email protected] --auth-only

I enter my password and I get the below. I double checked my password and I also login with these credentials at icloud.com - my account is not locked.

2024-11-09 22:32:10 DEBUG Authenticating...
iCloud Password:
2024-11-09 22:32:15 ERROR Service Temporarily Unavailable (503)
Traceback (most recent call last):
File "pyicloud_ipd\base.py", line 211, in authenticate
File "requests\sessions.py", line 637, in post
File "pyicloud_ipd\session.py", line 122, in request
File "pyicloud_ipd\session.py", line 196, in _raise_error
pyicloud_ipd.exceptions.PyiCloudAPIResponseException: Service Temporarily Unavailable (503)

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

Traceback (most recent call last):
File "starters\icloudpd.py", line 6, in
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 745, in main
File "icloudpd\base.py", line 1179, 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 219, in authenticate
pyicloud_ipd.exceptions.PyiCloudFailedLoginException: ('Invalid email/password combination.', PyiCloudAPIResponseException('Service Temporarily Unavailable (503)'))
[22268] Failed to execute script 'icloudpd' due to unhandled exception!

@HackerJL
Copy link

HackerJL commented Nov 9, 2024

I have been fighting with this for days. But along with a few other posts, the only way Ive had it work (and just fixed it 20 minutes ago myself) was to change my appleid password (which isn't a big deal cause it prompts you if you want to sign out of everything or not - I choose not). then re-ran the command and 2FA went through...

@AndreyNikiforov
Copy link
Collaborator

what version of icloudpd are you using?

@HackerJL
Copy link

what version of icloudpd are you using?

1.24.3. I updated to the new one last week which is what prompted my issues. I also found I had to delete the .pycloud folder from my home folder (Im on a Mac). Though not sure that was actually needed in truth.

@yaneury
Copy link

yaneury commented Nov 10, 2024

I think the issue is coming from the upstream pyicloud library: picklepete/pyicloud#456.

@petarlaf
Copy link

petarlaf commented Nov 10, 2024

what version of icloudpd are you using?

icloudpd-1.23.4 in my case

what version of icloudpd are you using?

1.24.3. I updated to the new one last week which is what prompted my issues. I also found I had to delete the .pycloud folder from my home folder (Im on a Mac). Though not sure that was actually needed in truth.

I will try today to reset my pw and see what happens. Although how does it make sense if the account is accesible from everywhere else (even private browser session and etc).. will report back

EDIT (again):

Ok I think on my end, at the end, changing the password and updating to 1.24.3 (from 1.23.4) worked. For some reason also my docker was failing to update itself and was using an old image so had to manually delete and redownload.

@AndreyNikiforov
Copy link
Collaborator

1.24.2 is the release where "Service Error 503" was [supposedly] fixed

@AndreyNikiforov
Copy link
Collaborator

I think the issue is coming from the upstream pyicloud library: picklepete/pyicloud#456.

We use forked version of that lib, but you are correct, that is the same issue

@LarsPoulsen
Copy link
Author

I uninstalled icloudpd and reinstalled it (1.24.3).
Problem has changed.
Now it starts authenticating, I get the 2FA prompt on my iPhone, and then it just hangs at
2024-11-10 14:10:30 DEBUG Authenticating...

Sometimes I get one more line of output

2024-11-10 14:05:17 DEBUG    Authenticating...
2024-11-10 14:05:18 ERROR    Authentication required for Account. (421)

So I still do not get logged in, much less start downloding.
And yes, I delete the .pyicloud folder. Made no difference.

@ildave
Copy link

ildave commented Nov 11, 2024

I have a similar issue, I just pulled the latest docker image, but I am getting this error when authenticating:

2024-11-11 08:15:13 DEBUG    Authenticating...
iCloud Password:
2024-11-11 08:15:21 ERROR    Authentication required for Account. (421)
Traceback (most recent call last):
  File "pyicloud_ipd/base.py", line 270, in authenticate
pyicloud_ipd.exceptions.PyiCloudAPIResponseException: {
  "serviceErrors" : [ {
    "code" : "-20101",
    "message" : "Enter the email or phone number and password for your Apple Account.",
    "suppressDismissal" : false
  } ]
} (401)

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

Traceback (most recent call last):
  File "starters/icloudpd_ex.py", line 122, in <module>
  File "starters/icloudpd_ex.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 745, in main
  File "icloudpd/base.py", line 1183, in core
  File "icloudpd/authentication.py", line 53, in authenticate_
  File "pyicloud_ipd/base.py", line 160, in __init__
  File "pyicloud_ipd/base.py", line 280, in authenticate
pyicloud_ipd.exceptions.PyiCloudFailedLoginException: ('Invalid email/password combination.', PyiCloudAPIResponseException('{\n  "serviceErrors" : [ {\n    "code" : "-20101",\n    "message" : "Enter the email or phone number and password for your Apple\xa0Account.",\n    "suppressDismissal" : false\n  } ]\n} (401)'))
[7] Failed to execute script 'icloudpd_ex' due to unhandled exception!

@CreativePR
Copy link

Still having the 401 error with one account only. Had user change the password and updated to Windows Version 1.24.3 Same error output as reported in version 1.24.0 version bug report

@iowk
Copy link
Contributor

iowk commented Nov 14, 2024

As @codebar33 reported gcobb321/icloud3#388 (comment), the password hash algorithm should depend on the protocol, which is in the response of signin/init.

Adding this implementation might help.

@dojoca
Copy link

dojoca commented Nov 21, 2024

Same problem here. Tried on Ubuntu (installed via Pip) and Alpine (installed via docker).

@dojoca
Copy link

dojoca commented Nov 24, 2024

Has anyone had an luck in getting this to work?

This is the error I am getting when I run icloudpd -u --auth-only

Traceback (most recent call last):
File "pyicloud_ipd/base.py", line 270, in authenticate
pyicloud_ipd.exceptions.PyiCloudAPIResponseException: {
"serviceErrors" : [ {
"code" : "-20101",
"message" : "Enter the email or phone number and password for your Apple Account.",
"suppressDismissal" : false
} ]
} (401)

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

Traceback (most recent call last):
File "starters/icloudpd.py", line 6, in
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 745, in main
File "icloudpd/base.py", line 1183, in core
File "icloudpd/authentication.py", line 53, in authenticate_
File "pyicloud_ipd/base.py", line 160, in init
File "pyicloud_ipd/base.py", line 280, in authenticate
pyicloud_ipd.exceptions.PyiCloudFailedLoginException: ('Invalid email/password combination.', PyiCloudAPIResponseException('{\n "serviceErrors" : [ {\n "code" : "-20101",\n "message" : "Enter the email or phone number and password for your Apple\xa0Account.",\n "suppressDismissal" : false\n } ]\n} (401)'))
[903122] Failed to execute script 'icloudpd' due to unhandled exception!

It seems like the script is failing because the server is asking for a username and password... but it's already been provided?

This is on ubuntu 22.04.5 LTS.

@LarsPoulsen
Copy link
Author

I am seeing a new version after twice installing and then reinstalling icloudpd to pick up updates.
It now hangs before login finishes. iCloud sends me the 6-digit code, but I am never prompted for it.
In the example below, I let it sit for 15 minutes before aborting it.

icloudpd -u [email protected] -p ?mypasswd? --recent 1 --folder-structure {:%Y/%m} --directory /pictures/Imports/?xxx?
2024-12-01 16:31:30 DEBUG    Authenticating...
2024-12-01 16:31:36 ERROR    Authentication required for Account. (421)
^C
Aborted!
Traceback (most recent call last):
  File "/usr/local/bin/icloudpd", line 5, in <module>
    from icloudpd import __main__
  File "/usr/local/lib/python3.12/site-packages/icloudpd/__main__.py", line 5, in <module>
    sys.exit(subprocess.call([os.path.join(os.path.dirname(__file__), "icloudpd"), *sys.argv[1:]]))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/subprocess.py", line 391, in call
    return p.wait(timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/subprocess.py", line 1264, in wait
    return self._wait(timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/subprocess.py", line 2053, in _wait
    (pid, sts) = self._try_wait(0)
                 ^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/subprocess.py", line 2011, in _try_wait
    (pid, sts) = os.waitpid(self.pid, wait_flags)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt

@Fontheweg
Copy link

Same here with 1.24.4 on MacOS installed with brew.

`icloudpd --username [email protected] --auth-only
2024-12-02 21:50:55 DEBUG Authenticating...
iCloud Password:
Traceback (most recent call last):
File "/usr/local/Cellar/icloudpd/1.24.4/libexec/lib/python3.13/site-packages/pyicloud_ipd/base.py", line 270, in authenticate
raise PyiCloudAPIResponseException(response.text, str(response.status_code))
pyicloud_ipd.exceptions.PyiCloudAPIResponseException: {
"serviceErrors" : [ {
"code" : "-20101",
"message" : "Enter the email or phone number and password for your Apple Account.",
"suppressDismissal" : false
} ]
} (401)

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

Traceback (most recent call last):
File "/usr/local/bin/icloudpd", line 8, in
sys.exit(main())
~~~~^^
File "/usr/local/Cellar/icloudpd/1.24.4/libexec/lib/python3.13/site-packages/click/core.py", line 1157, in call
return self.main(*args, **kwargs)
~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/icloudpd/1.24.4/libexec/lib/python3.13/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
File "/usr/local/Cellar/icloudpd/1.24.4/libexec/lib/python3.13/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/icloudpd/1.24.4/libexec/lib/python3.13/site-packages/click/core.py", line 783, in invoke
return _callback(*args, **kwargs)
File "/usr/local/Cellar/icloudpd/1.24.4/libexec/lib/python3.13/site-packages/icloudpd/base.py", line 745, in main
result = core(
download_builder(
...<50 lines>...
status_exchange,
)
File "/usr/local/Cellar/icloudpd/1.24.4/libexec/lib/python3.13/site-packages/icloudpd/base.py", line 1183, in core
icloud = authenticator(
...<8 lines>...
status_exchange,
)(
username,
...<2 lines>...
os.environ.get("CLIENT_ID"),
)
File "/usr/local/Cellar/icloudpd/1.24.4/libexec/lib/python3.13/site-packages/icloudpd/authentication.py", line 53, in authenticate

icloud = PyiCloudService(
filename_cleaner,
...<7 lines>...
client_id=client_id,
)
File "/usr/local/Cellar/icloudpd/1.24.4/libexec/lib/python3.13/site-packages/pyicloud_ipd/base.py", line 160, in init
self.authenticate()
~~~~~~~~~~~~~~~~~^^
File "/usr/local/Cellar/icloudpd/1.24.4/libexec/lib/python3.13/site-packages/pyicloud_ipd/base.py", line 280, in authenticate
raise PyiCloudFailedLoginException(msg, error) from error
pyicloud_ipd.exceptions.PyiCloudFailedLoginException: ('Invalid email/password combination.', PyiCloudAPIResponseException('{\n "serviceErrors" : [ {\n "code" : "-20101",\n "message" : "Enter the email or phone number and password for your Apple\xa0Account.",\n "suppressDismissal" : false\n } ]\n} (401)'))
`

@AndreyNikiforov
Copy link
Collaborator

v1.25.0 covers another auth edge case

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

10 participants