icloud-photos-downloader / icloud_photos_downloader

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

2FA login does not work anymore - Permission denied #129

Closed orappold closed 1 year ago

orappold commented 5 years ago

Hi everyone,

since a couple of days my script does not work anymore. During the Authentication step I do get a popup to enter my 2FA confirmation code, however I cannot enter it anywhere. That leads to a Permission denied "error 13" code.

Any ideas?

farnots commented 5 years ago

Maybe try to add App Specific password

makegofast commented 5 years ago

FWIW I used 2FA today without issue with version 1.4.3

VertigoRay commented 5 years ago

@farnots Suprisingly, the App Specific password did not work.

icloudpd /tmp/test-icloudpd --username my@me.com --password 'asdf-qwer-zxcv-uiop'
2019-02-26 09:59:05 DEBUG    Authenticating...
Traceback (most recent call last):
  ...
pyicloud_ipd.exceptions.PyiCloudFailedLoginException: ('Invalid email/password combination.', PyiCloudAPIResponseError('Unknown reason',))

Also tried without the quotes and with double quotes. Have you tested the App Specific password with this script?

That's a bit off-topic though. I was able to use 2FA with version 1.4.3.

boredazfcuk commented 5 years ago

@farnots Suprisingly, the App Specific password did not work.

Also tried without the quotes and with double quotes. Have you tested the App Specific password with this script?

Hi,

IIRC, I've see the question of App Specific passwords raised on here before and the reason it won't work is that it's not an App (Apps run on iDevices). The script logs in to iCloud.com and downloads the photos, just like if you did it in a browser.

andersjohansson commented 5 years ago

Could it be the issue that apple for some reason blocked linux user agents for a while? I don’t think that’s an issue any longer though. https://www.reddit.com/r/linux/comments/atc0av/apples_apple_id_management_site_blocks_linux/

boredazfcuk commented 5 years ago

I had to re-auth 2FA today and it's working fine. I have 1.4.3 installed.

One thing, if you are using the --notification-script option, it will not prompt for 2FA re-authentication. It will run the notification script and exit out. If it didn't, then the script would start stacking up each time it is launched from crontab, as they would all wait for 2FA re-authentication.

Presumably it works the same for e-mail notifications.

I just have a re-authentication script which runs icloudpd with no notification options and that does the trick.

menkej commented 4 years ago

Hi @orappold ! is this issue still valid? 2FA is quite stable for a long time now...

planetf1 commented 2 years ago

I wasn't able to login using master or 1.7.2, and get pyicloud_ipd.exceptions.PyiCloudFailedLoginException: ('Invalid email/password combination.', PyiCloudAPIResponseError('Unknown reason'))

I initially tried the app password, but then my real password. I have 2FA setup.

planetf1 commented 2 years ago
$ ./icloudpd.py --directory /data/photos/icloud --username "myemail@mydomain.com" --password "mypassword" --threads-num 4
 2022-03-07 18:03:52 DEBUG    Authenticating...
Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.7/site-packages/pyicloud_ipd/base.py", line 212, in authenticate
    data=json.dumps(data)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 581, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/home/pi/.local/lib/python3.7/site-packages/pyicloud_ipd/base.py", line 100, in request
    self._raise_error(code, reason)
  File "/home/pi/.local/lib/python3.7/site-packages/pyicloud_ipd/base.py", line 122, in _raise_error
    raise api_error
pyicloud_ipd.exceptions.PyiCloudAPIResponseError: Unknown reason
boredazfcuk commented 2 years ago

I had exactly same error on my other half’s account this weekend. When I logged on to iCloud.com, it said her account was locked and I then had to answer questions and confirm the password to unlock the account.

planetf1 commented 2 years ago

@boredazfcuk thanks for the tip. However I was able to login to icloud just fine (safari with touchid, but then chrome with user/pass + 2FA).

Same error from pi. Worth a try!

boredazfcuk commented 2 years ago

Make sure to delete your /config/ cookie file too. I did that first, but still got the same error, then unlocked my account and it went away.

I thought it was unlocking that fixed it, nut it could have been the combination of both things which did it.

planetf1 commented 2 years ago

@boredazfcuk thanks for that tip too - I have no cookie file, also tried with '--cookie-directory=/tmp' - same result

jamone19 commented 2 years ago

I am trying to copy thousands of files and I have been using the container for the last 3 days with no real issues. I was able to download 800+ files (many files were skipped).

But now I am getting an authentication issue. Note that I had to reset my iCloud password today and I am able to login to iCloud from my phone and a web browser.

I also renamed the cookies file to see if that was causing the issue, but it did not help.

Here is the error: podman run -it --rm --name icloud -v /home/tim/Pictures//2022:/home/data:Z -v /home/tim/cookies:/home/cookies:Z -e TZ=America\New_York icloudpd/icloudpd:latest icloudpd --directory /home/data --cookie-directory /home/cookies --folder-structure {:%Y/%Y-%m-%d} --username id --password pass --size original --recent 2000 2022-03-15 22:20:29 DEBUG Authenticating... Traceback (most recent call last): File "/usr/lib/python3.8/site-packages/pyicloud_ipd/base.py", line 209, in authenticate req = self.session.post( File "/usr/lib/python3.8/site-packages/requests/sessions.py", line 590, in post return self.request('POST', url, data=data, json=json, **kwargs) File "/usr/lib/python3.8/site-packages/pyicloud_ipd/base.py", line 100, in request self._raise_error(code, reason) File "/usr/lib/python3.8/site-packages/pyicloud_ipd/base.py", line 122, in _raise_error raise api_error pyicloud_ipd.exceptions.PyiCloudAPIResponseError: Unknown reason

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/bin/icloudpd", line 8, in sys.exit(main()) File "/usr/lib/python3.8/site-packages/click/core.py", line 722, in call return self.main(args, kwargs) File "/usr/lib/python3.8/site-packages/click/core.py", line 697, in main rv = self.invoke(ctx) File "/usr/lib/python3.8/site-packages/click/core.py", line 895, in invoke return ctx.invoke(self.callback, ctx.params) File "/usr/lib/python3.8/site-packages/click/core.py", line 535, in invoke return callback(args, **kwargs) File "/usr/lib/python3.8/site-packages/icloudpd/base.py", line 255, in main icloud = authenticate( File "/usr/lib/python3.8/site-packages/icloudpd/authentication.py", line 29, in authenticate icloud = pyicloud_ipd.PyiCloudService( File "/usr/lib/python3.8/site-packages/pyicloud_ipd/base.py", line 193, in init self.authenticate() File "/usr/lib/python3.8/site-packages/pyicloud_ipd/base.py", line 216, in authenticate raise PyiCloudFailedLoginException(msg, error) pyicloud_ipd.exceptions.PyiCloudFailedLoginException: ('Invalid email/password combination.', PyiCloudAPIResponseError('Unknown reason'))

Any help is appreciated.

mrbxzac commented 2 years ago

I am trying to copy thousands of files and I have been using the container for the last 3 days with no real issues. I was able to download 800+ files (many files were skipped).

But now I am getting an authentication issue. Note that I had to reset my iCloud password today and I am able to login to iCloud from my phone and a web browser.

I also renamed the cookies file to see if that was causing the issue, but it did not help.

Here is the error: podman run -it --rm --name icloud -v /home/tim/Pictures//2022:/home/data:Z -v /home/tim/cookies:/home/cookies:Z -e TZ=America\New_York icloudpd/icloudpd:latest icloudpd --directory /home/data --cookie-directory /home/cookies --folder-structure {:%Y/%Y-%m-%d} --username id --password pass --size original --recent 2000 2022-03-15 22:20:29 DEBUG Authenticating... Traceback (most recent call last): File "/usr/lib/python3.8/site-packages/pyicloud_ipd/base.py", line 209, in authenticate req = self.session.post( File "/usr/lib/python3.8/site-packages/requests/sessions.py", line 590, in post return self.request('POST', url, data=data, json=json, **kwargs) File "/usr/lib/python3.8/site-packages/pyicloud_ipd/base.py", line 100, in request self._raise_error(code, reason) File "/usr/lib/python3.8/site-packages/pyicloud_ipd/base.py", line 122, in _raise_error raise api_error pyicloud_ipd.exceptions.PyiCloudAPIResponseError: Unknown reason

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/bin/icloudpd", line 8, in sys.exit(main()) File "/usr/lib/python3.8/site-packages/click/core.py", line 722, in call return self.main(args, kwargs) File "/usr/lib/python3.8/site-packages/click/core.py", line 697, in main rv = self.invoke(ctx) File "/usr/lib/python3.8/site-packages/click/core.py", line 895, in invoke return ctx.invoke(self.callback, ctx.params) File "/usr/lib/python3.8/site-packages/click/core.py", line 535, in invoke return callback(args, kwargs) File "/usr/lib/python3.8/site-packages/icloudpd/base.py", line 255, in main icloud = authenticate( File "/usr/lib/python3.8/site-packages/icloudpd/authentication.py", line 29, in authenticate icloud = pyicloud_ipd.PyiCloudService( File "/usr/lib/python3.8/site-packages/pyicloud_ipd/base.py", line 193, in init** self.authenticate() File "/usr/lib/python3.8/site-packages/pyicloud_ipd/base.py", line 216, in authenticate raise PyiCloudFailedLoginException(msg, error) pyicloud_ipd.exceptions.PyiCloudFailedLoginException: ('Invalid email/password combination.', PyiCloudAPIResponseError('Unknown reason'))

Any help is appreciated.

I kept getting this too in the past 6 hours.... I was running a docker of the latest version

jamone19 commented 2 years ago

I am trying to copy thousands of files and I have been using the container for the last 3 days with no real issues. I was able to download 800+ files (many files were skipped). But now I am getting an authentication issue. Note that I had to reset my iCloud password today and I am able to login to iCloud from my phone and a web browser. I also renamed the cookies file to see if that was causing the issue, but it did not help. Here is the error: podman run -it --rm --name icloud -v /home/tim/Pictures//2022:/home/data:Z -v /home/tim/cookies:/home/cookies:Z -e TZ=America\New_York icloudpd/icloudpd:latest icloudpd --directory /home/data --cookie-directory /home/cookies --folder-structure {:%Y/%Y-%m-%d} --username id --password pass --size original --recent 2000 2022-03-15 22:20:29 DEBUG Authenticating... Traceback (most recent call last): File "/usr/lib/python3.8/site-packages/pyicloud_ipd/base.py", line 209, in authenticate req = self.session.post( File "/usr/lib/python3.8/site-packages/requests/sessions.py", line 590, in post return self.request('POST', url, data=data, json=json, kwargs) File "/usr/lib/python3.8/site-packages/pyicloud_ipd/base.py", line 100, in request self._raise_error(code, reason) File "/usr/lib/python3.8/site-packages/pyicloud_ipd/base.py", line 122, in _raise_error raise api_error pyicloud_ipd.exceptions.PyiCloudAPIResponseError: Unknown reason During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/bin/icloudpd", line 8, in sys.exit(main()) File "/usr/lib/python3.8/site-packages/click/core.py", line 722, in call return self.main(args, kwargs) File "/usr/lib/python3.8/site-packages/click/core.py", line 697, in main rv = self.invoke(ctx) File "/usr/lib/python3.8/site-packages/click/core.py", line 895, in invoke return ctx.invoke(self.callback, ctx.params) File "/usr/lib/python3.8/site-packages/click/core.py", line 535, in invoke return callback(args, kwargs) File "/usr/lib/python3.8/site-packages/icloudpd/base.py", line 255, in main icloud = authenticate( File "/usr/lib/python3.8/site-packages/icloudpd/authentication.py", line 29, in authenticate icloud = pyicloud_ipd.PyiCloudService( File "/usr/lib/python3.8/site-packages/pyicloud_ipd/base.py", line 193, in init self.authenticate() File "/usr/lib/python3.8/site-packages/pyicloud_ipd/base.py", line 216, in authenticate raise PyiCloudFailedLoginException(msg, error) pyicloud_ipd.exceptions.PyiCloudFailedLoginException: ('Invalid email/password combination.', PyiCloudAPIResponseError('Unknown reason')) Any help is appreciated.

I kept getting this too in the past 6 hours.... I was running a docker of the latest version

This is still not working for me, is it working for you now ?

synox commented 2 years ago

I saw the same error. I was not able to login to idcloud.com in the browser. Resetting the password resolved the problem.