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

[MacOS] Unknown reason authentication error #700

Closed
Brett-StrayThought opened this issue Oct 3, 2023 · 18 comments
Closed

[MacOS] Unknown reason authentication error #700

Brett-StrayThought opened this issue Oct 3, 2023 · 18 comments
Labels

Comments

@Brett-StrayThought
Copy link

Overview

I previously used icloudpd without issue. I copied/pasted the command I used last time (don't know which version) that worked but it doesn't work this time in 1.16.2. It fails trying to login with 2FA. I tried many times, and manually logged into iCloud to be sure username and password are indeed correct.

Note in the error it says "Failed to send two-factor authentication code" however I received the SMS and also every one of my Apple devices prompted me asking to Allow/Deny too.

Steps to Reproduce

  1. Run "icloudpd --directory /Users/brett/Downloads/iPhoneImport/Brett --username @icloud.com --password --recent 1340 --set-exif-datetime --folder-structure {:%Y/%m}"
  2. Results in error:
MBP iPhone Import$ icloudpd --directory /Users/brett/Downloads/iPhoneImport/Brett --username <my username>@icloud.com --password <my password> --recent 1340 --set-exif-datetime --folder-structure {:%Y/%m}
2023-10-03 10:31:22 DEBUG    Authenticating...
2023-10-03 10:31:23 INFO     Two-step/two-factor authentication is required
  0: SMS to ********10
  1: Enter two-factor authentication code
Please choose an option: [0]: Usage: icloudpd <options>
Try 'icloudpd -h' for help.

Error: No such option: -B

2023-10-03 10:31:59 ERROR    Failed to send two-factor authentication code
multiprocessing/resource_tracker.py:104: UserWarning: resource_tracker: process died unexpectedly, relaunching.  Some resources might leak.
MBP iPhone Import$ Usage: icloudpd <options>
Try 'icloudpd -h' for help.

Error: No such option: -B

MBP iPhone Import$ 

Expected Behavior

Expected it would work, or give a better reason for failure. Especially unsure what the "Error: No such option: -B" that pops up means.

Actual Behavior

Didn't work

Context

@boredazfcuk
Copy link
Contributor

Does your password have a -B in it by any chance?

@Brett-StrayThought
Copy link
Author

Good question! But it does not. It doesn't contain anything other than letters/numbers. Same for username.

@Brett-StrayThought
Copy link
Author

I did some Googling, and the "Error: No such option: -B" is odd and I could only find one other person who mentioned it.

https://www.mactechnews.de/journals/entry/iCloud-Mediathek-exportieren-und-Originale-sichern-1046.html

@MrChad0815
Copy link

To the best of my knowledge, the ever-repeating misleading message

| Usage: icloudpd
| Try 'icloudpd -h' for help.
|
| Error: No such option: -B

appears on Apple Silicon machines (only?) and has no other negative effects

It is somehow caused by the interaction of the Python runtime system (multiprocessing libraries) and Apple's Rosetta machine code translation.
The Python runtime system seems to believe the program has crashed and tries to restart it with some strange arguments "-B" and a few others others.

@Brett-StrayThought
Copy link
Author

Interesting. I'm on an Intel MacBook Pro so I don't think in this case it could be that.

@AndreyNikiforov
Copy link
Collaborator

Last time I saw option -B mentioned was in the context of ADP in #687 . In general, ADP & icloudpd do not work together.

@MrChad0815
Copy link

MrChad0815 commented Oct 3, 2023

not related to ADP - as it is not in use here
.---------------------------------
you can work around the issue in your main() like this:

def main():
try:
# when this is called from within an app-bundle
# the multiprocessing.resource_tracker kicks in after every download
# and tries to start a second instance with several (unknown) arguments
# possibly due to a leak of some sort
# this code will detect the arguments and terminate the secondary instance when it starts
for a in sys.argv:
if 'multiprocessing.resource_tracker' in a:
sys.exit(1)
finally:
pass

.# followed by your code

.------------------------------------
The second instance will receive a series of arguments including a string ... multiprocessing.resource_tracker ... originating from:
https://github.com/python/cpython/blob/main/Lib/multiprocessing/resource_tracker.py (see line 131)

@Brett-StrayThought
Copy link
Author

I went back to the original repo for pyicloud and found it works fine with no errors or the strange "not option -B" error. So before moving on, summary is:

  • When 2FA is enabled (which is now enabled by default and once enabled can't be disabled), there are exceptions that occur which aren't handled and don't produce very good error reporting. Ideally this would be improved.
  • There is a strange spurious "Error: No such option: -B" that occurs which doesn't occur in the original pyicloud implementation.

@alixmartineau
Copy link

alixmartineau commented Oct 4, 2023

I have had the same problem for a while (icloudpd, version 1.14.5 on Apple M2 Pro, Python 3.11.5)

$ icloudpd --directory 'Photos' --username 'xxx@xxx.xxx' --auto-delete
2023-10-04 12:57:08 DEBUG    Authenticating...
iCloud Password: 
2023-10-04 12:57:18 DEBUG    Looking up all photos and videos from album All Photos...
2023-10-04 12:57:18 INFO     Downloading 5002 original photos and videos to Photos ...
  0%|                                                                                                  | 0/5002 [00:00<?, ?it/s]Usage: icloudpd <options>
Try 'icloudpd -h' for help.

Error: No such option: -B
Photos/2014/12/24/IMG_0062.JPG already exists.: 100%|#######################################| 5002/5002 [05:22<00:00, 15.53it/s]2023-10-04 13:02:41 INFO     All photos have been downloaded!
2023-10-04 13:02:41 INFO     Deleting any files found in 'Recently Deleted'...
multiprocessing/resource_tracker.py:104: UserWarning: resource_tracker: process died unexpectedly, relaunching.  Some resources might leak.

Usage: icloudpd <options>
Try 'icloudpd -h' for help.

Error: No such option: -B

I should clarify that icloudpd still works, the pictures are downloaded as expected, but the output is all mangled and unreadable.

Happens both with zsh and bash.

I also tried : different --log-levels, passing password as an argument, --no-progress-bar but these errors still get printed to stdout.

@AndreyNikiforov
Copy link
Collaborator

Resource leak was noticed on mac before (#668), although symptoms were different.

@alixmartineau
Copy link

Thanks @AndreyNikiforov, just tested icloudpd==1.14.2 and the problem is not present.

@flappah
Copy link

flappah commented Oct 27, 2023

I think it has to do with the existence of security keys in the apple-id. I had a similar error and after removing both security keys from my apple-id icloudpd worked again.

@itwasabhi
Copy link

+1 with this issue (icloudpd, version 1.16.2), Apple M2

@juju4
Copy link

juju4 commented Nov 19, 2023

I think it has to do with the existence of security keys in the apple-id. I had a similar error and after removing both security keys from my apple-id icloudpd worked again.

Any plan to support security keys (FIDO2/webauthn)?
It seems that when configured, OTP is not available anymore. Also security keys configuration remove existing MFA sessions. Tested with icloudpd 1.16.2. Need to remove them to use OTP again.

https://support.apple.com/en-ca/guide/iphone/iph5acc5b28c/ios
"Note: If you remove all security keys from a device, the device reverts to using six-digit verification codes for two-factor authentication."

@gaffneyd4
Copy link

If this error is caused by FIDO security keys being enabled as the 2FA method on the icloud account, then we can close this issue in favor of #583

@alixmartineau
Copy link

alixmartineau commented Nov 25, 2023 via email

@AndreyNikiforov AndreyNikiforov changed the title Unknown reason authentication error [MacOS] Unknown reason authentication error Dec 3, 2023
AndreyNikiforov added a commit to AndreyNikiforov/icloud_photos_downloader that referenced this issue Dec 4, 2023
AndreyNikiforov added a commit that referenced this issue Dec 4, 2023
@tooluser
Copy link

I have the same issue on my Intel Mac mini, v 1.16.2, no FIDO security key.

@AndreyNikiforov
Copy link
Collaborator

I have the same issue on my Intel Mac mini, v 1.16.2, no FIDO security key.

Upgrade to 1.17.1. Versions prior to 1.17.0 stoped working recently due to changes in Apple API, See #729

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