icloud-photos-downloader / icloud_photos_downloader

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

SMS MFA code not accepted #993

Closed boredazfcuk closed 6 days ago

boredazfcuk commented 2 weeks ago

Overview

Received an MFA code and input it, but authentication failed.

2024-11-09 17:02:49 DEBUG    Authenticating...
2024-11-09 17:02:52 INFO     Two-factor authentication is required (2fa)
  a: ***** ****01
  b: ***** ****02
Please enter two-factor authentication code or device index (a..b) to send SMS with a code: a
Please enter two-factor authentication code that you received over SMS: 060488
2024-11-09 17:03:10 ERROR    Failed to verify two-factor authentication code
2024-11-09 17:03:10 ERROR    Multifactor authentication information missing from cookie. Authentication has failed
2024-11-09 17:03:10 ERROR     - Was the correct password entered?
2024-11-09 17:03:10 ERROR     - Was the multifactor authentication code mistyped?
2024-11-09 17:03:10 ERROR     - Can you log into icloud.com without receiving pop-up notifications?
2024-11-09 17:03:10 INFO     Container initialisation complete

I've definitely entered the code correctly... but I've noticed that the code starts with a 0... was just wondering if it's that bug where it strips leading zeros again? Was thinking it may be worth checking... if it's not a reoccurrence of that issue, then just close the issue.

AndreyNikiforov commented 2 weeks ago

Multifactor authentication information missing from cookie is not part of the codebase in this project. Do you mind posting output from icloudpd itself (binary/docker preferable over src) to reduce the number of variables.

boredazfcuk commented 2 weeks ago

The output from the icloudpd binary was just this bit at the top:

2024-11-09 17:02:49 DEBUG    Authenticating...
2024-11-09 17:02:52 INFO     Two-factor authentication is required (2fa)
  a: ***** ****01
  b: ***** ****02
Please enter two-factor authentication code or device index (a..b) to send SMS with a code: a
Please enter two-factor authentication code that you received over SMS: 060488
2024-11-09 17:03:10 ERROR    Failed to verify two-factor authentication code

The bit beneath is just a check to make sure the cookie is MFA capable. When MFA authentication is successful 'X-APPLE-WEBAUTH-HSA-TRUST' gets added to the cookie, so I just check it's present... basically just:

      if [ "$(grep -c "X-APPLE-WEBAUTH-HSA-TRUST" "/config/${cookie_file}")" -eq 1 ]; then
         LogInfo "Multifactor authentication cookie generated. Sync should now be successful"
      else
         LogError "Multifactor authentication information missing from cookie. Authentication has failed"
         LogError " - Was the correct password entered?"
         LogError " - Was the multifactor authentication code mistyped?"
         LogError " - Can you log into ${icloud_domain} without receiving pop-up notifications?"
      fi
AndreyNikiforov commented 2 weeks ago

Your suspicion on dropping leading zeros for sms code was right.

AndreyNikiforov commented 2 weeks ago

995

boredazfcuk commented 2 weeks ago

Great stuff

AndreyNikiforov commented 6 days ago

v1.24.4+