icloud3 icon indicating copy to clipboard operation
icloud3 copied to clipboard

Unable to re-login to Apple account

Open weiyifeng73 opened this issue 5 months ago • 29 comments

After using it for a while, I experienced login failures. Even after re-entering the verification code, the system still states the account login failed. I could only successfully log in after deleting the account and creating a new one. I wonder if there's something wrong with my steps?

Image

weiyifeng73 avatar Jul 15 '25 14:07 weiyifeng73

Did you look at the Event Log to see what the errors were?

gcobb321 avatar Jul 15 '25 14:07 gcobb321

07-15 22:38:55 1stLOC Requesting Initial Locate 07-15 22:39:57 ------ DATA_SOURCE (update_apple_acct) > UserInput-{'apple_accts': 'ss192@ → ⛔ NOT LOGGED IN DUE TO ANOTHER ERROR, SEE EVENT LOG', 'data_source': 'iCloud,MobApp'}, Errors-{} 07-15 22:39:57 ------ DATA_SOURCE (update_apple_acct) > UserInput-{'apple_accts': 'ss192@', 'data_source': 'iCloud,MobApp'}, Errors-{} 07-15 22:40:25 ------ ss092@, Initialize PyiCloud Service, Set up iCloud Location Services connection 07-15 22:40:25 ------ ss092@, Authenticate with Token 07-15 22:40:25 ------ ss092@, Authenticate with Password 07-15 22:40:25 ------ 🔺 SSCHEN_92, POST, REQUEST, AUTHENTICATE_WITH_PASSWORD/822 ▲ ❗ items={'url': 'idmsa.apple.com/appleauth/auth/signin', 'retry': 0, 'json': None} ❗ headers={'Accept': '/', 'X-Apple-OAuth-State': 'auth-a……54a452'} ❗ data.items={'accountName': 'ss092@'} 07-15 22:40:29 ------ 🔻 SSCHEN_92, POST, RESPONSE, AUTHENTICATE_WITH_PASSWORD/822 ▼ ❗ items={'code': 200, 'ok': True} 07-15 22:40:29 ------ 🔺 SSCHEN_92, POST, REQUEST, _AUTHENTICATE_WITH_TOKEN/744 ▲ ❗ items={'url': 'setup./setup/ws/1/accountLogin', 'retry': 0, 'json': None} ❗ data.items={'accountCountryCode': 'CHN', 'dsWebAuthToken': 'Ah/jzz……gZUig=', 'extended_login': True, 'trustToken': ''} 07-15 22:40:36 ------ 🔻 SSCHEN_92, POST, RESPONSE, _AUTHENTICATE_WITH_TOKEN/744 ▼ ❗ items={'code': 302, 'ok': True} 07-15 22:40:36 ------ ss092@, Authentication Failed, Apple Server Location-/config/.storage/icloud3.apple_acct, Apple Server not Available (Connection Refused or Other Error), ErrorCode-302 07-15 22:40:36 ------ Apple Acct > ss092@, Login Failed, Error-302, Apple Server not Available (Connection Refused or Other Error), AppleServerLocation-/config/.storage/icloud3.apple_acct, Location Data not Refreshed 07-15 22:40:36 ------ iCloud3 Error > Apple Acct > ss092@, Login Failed, Error-302, Apple Server not Available (Connection Refused or Other Error), AppleServerLocation-/config/.storage/icloud3.apple_acct, Location Data not Refreshed 07-15 22:41:02 ------ 🔺 SSCHEN_92, POST, REQUEST, VALIDATE_2FA_CODE/1353 ▲ ❗ items={'url': 'idmsa.apple.com/appleauth/auth/verify/trusteddevice/securitycode', 'retry': 0, 'json': None} ❗ headers={'Accept': '/', 'X-Apple-OAuth-State': 'auth-a……54a452', 'X-Apple-ID-Session-Id': 'A46567……A7DC1E'} 07-15 22:41:19 ------ 🔻 SSCHEN_92, POST, RESPONSE, VALIDATE_2FA_CODE/1353 ▼ ❗ items={'code': 404, 'ok': False} 07-15 22:41:19 ------ 🔺 SSCHEN_92, GET, REQUEST, TRUST_SESSION/1384 ▲ ❗ items={'url': 'idmsa.apple.com/appleauth/auth/2sv/trust', 'retry': 0} ❗ headers={'Accept': '/', 'X-Apple-OAuth-State': 'auth-a……54a452', 'X-Apple-ID-Session-Id': 'A46567……A7DC1E'} 07-15 22:41:20 ------ 🔻 SSCHEN_92, GET, RESPONSE, TRUST_SESSION/1384 ▼ ❗ items={'code': 204, 'ok': True} 07-15 22:41:20 ------ 🔺 SSCHEN_92, POST, REQUEST, _AUTHENTICATE_WITH_TOKEN/744 ▲ ❗ items={'url': 'setup./setup/ws/1/accountLogin', 'retry': 0, 'json': None} ❗ data.items={'accountCountryCode': 'CHN', 'dsWebAuthToken': 'qG/X4n……xewmc=', 'extended_login': True, 'trustToken': 'HSARMT……5rSRVX'} 07-15 22:41:22 ------ 🔻 SSCHEN_92, POST, RESPONSE, _AUTHENTICATE_WITH_TOKEN/744 ▼ ❗ items={'code': 302, 'ok': True} 07-15 22:41:52 ------ ss092@, Initialize PyiCloud Service, Set up iCloud Location Services connection 07-15 22:41:52 ------ 🔺 SSCHEN_92, POST, REQUEST, VALIDATE_WITH_VERIFY_VIA_URL/305 ▲ ❗ items={'url': 'setup./setup/authenticate/ss092@', 'retry': 0, 'data': None, 'json': None} ❗ headers={'Authorization': 'Basic ……Y0Mw=='} 07-15 22:42:01 ------ 🔻 SSCHEN_92, POST, RESPONSE, VALIDATE_WITH_VERIFY_VIA_URL/305 ▼ ❗ items={'code': 409, 'ok': False} 07-15 22:42:09 ------ ss092@, Initialize PyiCloud Service, Set up iCloud Location Services connection 07-15 22:42:09 ------ 🔺 SSCHEN_92, POST, REQUEST, VALIDATE_WITH_VERIFY_VIA_URL/305 ▲ ❗ items={'url': 'setup./setup/authenticate/ss092@', 'retry': 0, 'data': None, 'json': None} ❗ headers={'Authorization': 'Basic ……Y0Mw=='} 07-15 22:42:13 ------ 🔻 SSCHEN_92, POST, RESPONSE, VALIDATE_WITH_VERIFY_VIA_URL/305 ▼ ❗ items={'code': 409, 'ok': False}

Image

weiyifeng73 avatar Jul 15 '25 14:07 weiyifeng73

You have selected the China server location but I do not see the China endpoint suffix on the url in the log file. Exit the Configure, then go back in and try again.

The .storage/icloud3/configuration file will have the apple_account parameters that has the server_location parameter. It should be 'cn' ''' "apple_accounts": [ { "username": xxxx@xxxx", "password": "*******", "totp_key": "", "locate_all": true, "server_location": "cn" } ], '''

If it does, restart iCloud3 and try again.

gcobb321 avatar Jul 15 '25 15:07 gcobb321

the "server_location" is ".cn,GCJ02"

Image

weiyifeng73 avatar Jul 15 '25 15:07 weiyifeng73

oh,oh,it works,I successfully restarted HA, but I failed to restart iCloud just now.

weiyifeng73 avatar Jul 15 '25 15:07 weiyifeng73

The ".cn" is correct.

I just noticed in your original image it had an entry of: AppleServerLocation='/config/.storage/icloud3.apple_acct'

It should be: AppleServerLocation='.cn'

gcobb321 avatar Jul 15 '25 15:07 gcobb321

Is this problem caused by my not restarting HA?

weiyifeng73 avatar Jul 15 '25 16:07 weiyifeng73

No. It is like the intervariable that has the server_location is being set to the location of the cookie files. Looking at it now.

What version of iCloud3 are you running. I just updated to v3.2.3 on the development site 3-days ago but I think this bug has been there.

gcobb321 avatar Jul 15 '25 16:07 gcobb321

The version I'm currently using is v3.2.2.3

weiyifeng73 avatar Jul 15 '25 16:07 weiyifeng73

See here for the Release Notes for v3.2.3.

v3.2.3.1 below contains a few fixes to v3.2.3 above.

Unzip into the icloud3 directory and restart HA.

Edit: ~icloud3 v3.2.3.1b1.zip~

Then lets see if it works correctly.

Edit: Updated the zip file--- icloud3 v3.2.3.1b1.zip

gcobb321 avatar Jul 15 '25 16:07 gcobb321

Okay, I'll try using this version for a while. Thank you.

weiyifeng73 avatar Jul 15 '25 16:07 weiyifeng73

I updated the icloud3 v3.2.3b1.zip file. The old one is crossed out. The correct one is in blue and at the bottom of the above note. Make sure you got the correct one.

gcobb321 avatar Jul 15 '25 16:07 gcobb321

I am having issues with my account also. A few days ago I started getting flooded with relogins from iCloud 3. So, I decided to remove all of the cache and config for iCloud3 from my home-assistant. I then removed and reinstalled iCloud3 and ever since my account wont' validate. Here is a brief summary of what I just tried and the result.

Got stuck at the Update Apple Account Username/Password screen. Did get a popup from Apple that someone was logging in and I received a 6 digit code. However, the iCloud3 Window eventually said “Unknown Error Occurred.”

Went to the Apple ID Verification Code screen anyways and put the code in. Got a spinning progress wheel and eventually it gave me an “Unknown Error Occurred” again.

On this screen I think requested a new apple account verification code. And I received it. I clicked allow and got a 6 digit code. The Apple ID Verification Code screen in iCloud3 just stayed the same with the spinning progress bar and wouldn’t do anything for a while. It eventually timed out. I then entered the 6 digit code and tried to send it, but that still didn’t work.

Note: This most recent attempt was with the v3.2.3.1b1.zip you posted above.

ssilence5 avatar Jul 24 '25 20:07 ssilence5

Are you using ipv6? That is not supported and will prevent Apple from sending info back to iCloud3.

gcobb321 avatar Jul 24 '25 21:07 gcobb321

Yep, that was it. It is working now.

ssilence5 avatar Jul 24 '25 21:07 ssilence5

I am trying to detect this error and would like your help. I have a development update that determines the IP address of the iCloud.com url I use to detect internet connection issues. It displays this zip address in the Event Log when iCloud3 starts. I posted it on another issue but he has a complicated setup and has not been able to install and test it yet.

Can you download and install the zip file, turn ipv6 on again and run it. It also moves a lot of the start up process to run after HA has started instead of running while HA is starting. This prevents errors like this from hanging HA itself while it waits for iCloud3 to finish loading. Post a screenshot of the Event Log entries.

You can find the v3.2.3b2 file here

Scroll up a few entries to see what will be displayed

Thanks. Gary

gcobb321 avatar Jul 24 '25 21:07 gcobb321

Do I need to remove my account first from iCloud3 or just copy and paste this over the install, turn on ipv6 and restart?

ssilence5 avatar Jul 24 '25 22:07 ssilence5

Keep your current config. Unzip. Turn on IPv6 restart HA. Get info. Take screenshot. Turn off IPv6. Restart HA and use the b2 version. Let me know if anything breaks or looks strange or throws errors. You bang always reinstall the HACS version again if things don’t work as expected.

gcobb321 avatar Jul 24 '25 22:07 gcobb321

Is this what you expected to see?

Image Image

ssilence5 avatar Jul 24 '25 22:07 ssilence5

No. These look like ipv4 IP addresses., not ipv6 addresses. Did you change the HA _system> network _ settings to set ipv6 to automatic before restarting HA?

gcobb321 avatar Jul 24 '25 23:07 gcobb321

Hmm...I had both ipv4 and ipv6 enabled/set to automatic. Do I need to disable the ipv4?? Also, wouldn't this setting only affect my internal LAN and not the WAN?

ssilence5 avatar Jul 24 '25 23:07 ssilence5

I completely disabled ipv4 and left ipv6 automatic and restarted. I then got this (doens't look much different).

Image

I then do a restart of icloud3 and now it is stuck here:

Image

ssilence5 avatar Jul 24 '25 23:07 ssilence5

Well, I am back to ipv4 only now. Having it on ipv6 only I did a reboot of the RPI4 and afterwards couldn't login. Had to connect up through the console to enable ipv4 back.

The internet connect error green bar was a change to prevent it from killing the HA startup. Turning ipv6 off like you did before and restarting will cause iCloud3 to start normally

ssilence5 avatar Jul 25 '25 00:07 ssilence5

When I mentioned that it might be caused by ipv6, what did you do to turn ipv6 off so iCloud3 would work? Was it an HA setting or on your HA server or router?

gcobb321 avatar Jul 25 '25 01:07 gcobb321

I made the change in the HA settings. I am running HAOS on a RPI4. I didn’t make any changes on my router or my modem.

ssilence5 avatar Jul 25 '25 01:07 ssilence5

Ok. I was hoping getting the primary IP address being used with the Python requests module. That handles internet traffic for iCloud3 would return an ipv6 faddress with the ‘:’ in it that I could use. It didn’t so I need to keep looking more method that detects if ipv6 is being used.

I am running with haos on an rpi5 and have ipv4 and ipv6 set to auto in the HA network settings. HA has never given me an error. It uses ipv4 always. I wonder why your setup failed.

gcobb321 avatar Jul 25 '25 01:07 gcobb321

What's weird is I have been using iCloud3 for a few years now but have been setup on my RPI4 with HASSIO via Supervised install. My initial setup was probably setup as IPV4 only. I switched to HAOS about a month ago which probably enabled both IPv4 and IPv6, but I didn't start having issues until last week (a few weeks after switching). Very strange.

ssilence5 avatar Jul 25 '25 15:07 ssilence5

I am getting Internet Connection Errors on my system running through Docker (though connected to the host network which does have ipv6). However, it is working fine mostly. Am I seeing these errors due to ipv6?

bradnak avatar Aug 12 '25 13:08 bradnak

There are times when iCloud3 sends a device or location request to Apple and Apple never responds. v3.2.4 has a timeout to catch this type of error. Users who have had this problem have disabled IPv6 on the HA Settings > System > Network screen and things go back to normal operations. iCloud3 sends a request to Apple and Apple responds.

I will be posting this tomorrow or Saturday on the iCloud3 Development repository as a new release.

Unzip it into the icloud3 directory and restart HA and see what happens. If the timeout error occurs, you will get an error message in the Event Log and an alert will be posted to the sensor.icloud3_alerts entity.

icloud3 v3.2.4.zip

iCloud3 ➤ v3.2.4 (8/15/2025)

🐛 Bug Fixes

  1. Dashboard Builder:
    • Fixed an error reading the base template and dashboard files that are used to construct new dashboards.
    • Fixed a problem where all devices would be inserted into a dashboards instead of only the selected ones.
  2. iCloud3 Log File - Fixed a problem when the log-level was set to 'unfiltered'.

🎉 Improvements

  1. Internet Connection Error - Added the following:
    • The Event Log error description message and alerts are added after the internet has been down for 1-minute to prevent very short dropouts from creating a lot of unnecessary messages.
    • Improved the error detection and testing done when verifying that Apple (icloud.com) can be connected to after the Internet is back online.
    • Added a 1-minute timeout to catch Apple location requests that have not been responded to. This is usually caused by IPv6 being enabled in HA. Appropriate tests and error messages explain that it is probably an IPv6 issue with instructions on how to disable it.
    • Improved the status message display messages.
  2. iCloud3 Startup:
    • iCloud3 starts after HA has finished loading to prevent HA from locking up due to any iCloud3 errors.
    • Significantly reduced the startup time when the log_level was set to debug (4 devices with 15 sensors went from pver 10-secs to less than 1-sec).
  3. Device Tracking - Devices not using the Mobile App (Watches) that are near other devices will be located 1-minute after the other devices have left a zone. This is not perfect and relies on Apple providing updated location data when it is relocated.
  4. Device Setup - Added Device Type categories to indicate if the iPad and Watch is WiFi only or Wifi+Cell.
  5. Tracking Results - The source of the GPS is displayed on the Event Log when a device's location is updated (GPS, WiFi, Cell, Unknown).
  6. iCloud3 Log File:
    • Configuration file records were added to the log file when the log_level is set to info or debug.
    • Fixed some problems formatting the log_level debug records.

gcobb321 avatar Aug 14 '25 20:08 gcobb321