steilerDev/icloud-photos-sync

Sync failed after activating mfa token

Closed this issue · 16 comments

I'm trying to setup sync in docker.

  1. Create docker-compose and up / run
  2. Obtain Token
  3. Use script to pass mfa code
  4. Trigger sync

At step 4 I receive the following error:

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Experienced fatal error at 2/10/2023, 7:08:13 AM: SyncError (FATAL): Sync failed caused by iCloudError (FATAL): Authentication failed caused by iCloudError (FATAL): Unexpected HTTP code: 412 caused by Request failed with status code 412 (Error Code: 175f5fd1-47e8-4d8d-a568-95a9cf2d8232)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Log:

[2023-02-10T06:12:32.805Z] INFO i-Cloud: Initiating iCloud connection
[2023-02-10T06:12:32.806Z] DEBUG MFA-Server: Preparing MFA server on port 80
[2023-02-10T06:12:32.808Z] DEBUG i-Cloud-Auth: Trying to load trust token from disk
[2023-02-10T06:12:32.808Z] DEBUG i-Cloud-Auth: Acquired trust token from file
[2023-02-10T06:12:32.897Z] INFO i-Cloud: Authenticating user
[2023-02-10T06:12:34.603Z] ERROR Error-Handler: SyncError (FATAL): Sync failed caused by iCloudError (FATAL): Authentication failed caused by iCloudError (FATAL): Unexpected HTTP code: 412 caused by Request failed with status code 412 (Error Code: 27d405d4-1b61-4c8f-b9c1-7c54108ac068)

Operating environmnent

  • OS: Arch
  • Version: 1.0.1
  • Execution environment: Docker

@bbsan2k I worked on this a little bit, could you please pull the latest nightly build, enable debug logging and crash reporting and report back?

Thanks for looking into it!
I at least get another error:

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Experienced fatal error at 2/18/2023, 12:23:31 PM: AppError (FATAL): Sync failed caused by iCloudAuthError (FATAL): iCloud Authentication failed caused by iCloudAuthError (FATAL): Unexpected HTTP response caused by Request failed with status code 412 (Error Code: f5f8ccd7-ab04-4c04-910c-ccea3e5de77e)
context:{}
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

log:

[2023-02-18T11:23:29.513Z] INFO i-Cloud: Initiating iCloud connection
[2023-02-18T11:23:29.514Z] DEBUG MFA-Server: Preparing MFA server on port 80
[2023-02-18T11:23:29.516Z] DEBUG i-Cloud-Auth: Trying to load trust token from disk
[2023-02-18T11:23:29.558Z] DEBUG i-Cloud-Auth: Acquired trust token from file
[2023-02-18T11:23:29.667Z] INFO i-Cloud: Authenticating user
[2023-02-18T11:23:31.291Z] ERROR Error-Handler: AppError (FATAL): Sync failed caused by iCloudAuthError (FATAL): iCloud Authentication failed caused by iCloudAuthError (FATAL): Unexpected HTTP response caused by Request failed with status code 412 (Error Code: f5f8ccd7-ab04-4c04-910c-ccea3e5de77e)
context:{}

Ok, that's interesting...
If I sync without manually acquiring a token before it runs.
On the next sync I get the error above - so it seems there is some issue with token based re-authentication

Are you using either (1) iCloud Shared Photo Library and/or (2) Advanced Data Protection?

Yep, (1)

Potential duplicate of #128

@bbsan2k 4a03260 has added experimental support for shared Photo Library - have a try on the nightly docker image tag and see if your issue persists

Thanks for the heads up - but unfortunately still the same issue...

Do you have a new error code?

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Welcome to icloud-photos-sync, v.1.1.0-beta!
Made with <3 by steilerDev
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Authenticating user...
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Experienced fatal error at 3/11/2023, 12:23:04 PM: AppError (FATAL): Sync failed caused by iCloudAuthError (FATAL): iCloud Authentication failed caused by iCloudAuthError (FATAL): Unexpected HTTP response caused by Request failed with status code 412 (Error Code: a005b26e-3853-48cb-9c63-293868500c3d)
context:{}
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 bbsan@archserver   ~ 

That's weird - are you able to login to icloud.com through the browser?

Yes, without any issues

I know exactly where the error is happing: This is the first request send to the backend containing your username, password and trust token. This should lead to either (200) Authentication Successful or (409) Conflict -> MFA required.

Your account however responds with 412 (Precondition failed). And I don't know how to handle this...

Could you look at the network logs of your browser right after you entered the password. There should be a POST to the /signin endpoint. How does it respond and what happens next?

LOL. Ok I figured it out: icloud is forcing me to change my password because it thinks it is not secure enough. Never saw this prompt before, as I normally login using Safari.
After changing my password it is fixed!

Awesome, let me put in an error message for HTTP 412 indicating to check the password requirements for future users! :)

Closed by f521f32