home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
70.58k stars 29.5k forks source link

iCloud requires re-authentication with in-app password after reboot #121784

Open estebanz01 opened 1 month ago

estebanz01 commented 1 month ago

The problem

Hola! 👋

The iCloud integration throws an error after a reboot and it cannot longer authenticate automatically with the in-app password. I haven't tried to reconfigure it as I'm debugging other issues I have with my HA instance, so there's that 😛

What version of Home Assistant Core has the issue?

core-2024.7.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Core

Integration causing the issue

icloud

Link to integration documentation on our website

https://www.home-assistant.io/integrations/icloud

Diagnostics information

version core-2024.7.2
installation_type Home Assistant Core
dev false
hassio false
docker false
user homeassistant
virtualenv true
python_version 3.12.2
os_name Linux
os_version 6.1.29-v8+
arch aarch64
timezone America/Bogota
config_dir /home/homeassistant/.homeassistant
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 5000 Installed Version | 1.34.0 Stage | running Available Repositories | 1385 Downloaded Repositories | 4
Home Assistant Cloud logged_in | true -- | -- subscription_expiration | 8 January 2025 at 19:00 relayer_connected | true relayer_region | us-east-1 remote_enabled | true remote_connected | true alexa_enabled | false google_enabled | true remote_server | us-east-1-0.ui.nabu.casa certificate_status | ready instance_id | ec70fa5f3e744848a672131e4f14a08f can_reach_cert_server | failed to load: timeout can_reach_cloud_auth | failed to load: timeout can_reach_cloud | ok
Dashboards dashboards | 6 -- | -- resources | 5 views | 12 mode | storage
Recorder oldest_recorder_run | 1 July 2024 at 14:36 -- | -- current_recorder_run | 10 July 2024 at 11:57 estimated_db_size | 240.31 MiB database_engine | mysql database_version | 10.5.23

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Here's the error:

Jul 11 10:04:20 raspberrypi hass[1425896]: Traceback (most recent call last):
Jul 11 10:04:20 raspberrypi hass[1425896]:   File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/config_entries.py", line 586, in async_setup
Jul 11 10:04:20 raspberrypi hass[1425896]:     result = await component.async_setup_entry(hass, self)
Jul 11 10:04:20 raspberrypi hass[1425896]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jul 11 10:04:20 raspberrypi hass[1425896]:   File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/components/icloud/__init__.py", line 102, in async_setup_entry
Jul 11 10:04:20 raspberrypi hass[1425896]:     await hass.async_add_executor_job(account.setup)
Jul 11 10:04:20 raspberrypi hass[1425896]:   File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
Jul 11 10:04:20 raspberrypi hass[1425896]:     result = self.fn(*self.args, **self.kwargs)
Jul 11 10:04:20 raspberrypi hass[1425896]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jul 11 10:04:20 raspberrypi hass[1425896]:   File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/components/icloud/account.py", line 138, in setup
Jul 11 10:04:20 raspberrypi hass[1425896]:     api_devices = self.api.devices
Jul 11 10:04:20 raspberrypi hass[1425896]:                   ^^^^^^^^^^^^^^^^
Jul 11 10:04:20 raspberrypi hass[1425896]:   File "/srv/homeassistant/lib/python3.12/site-packages/pyicloud/base.py", line 543, in devices
Jul 11 10:04:20 raspberrypi hass[1425896]:     return FindMyiPhoneServiceManager(
Jul 11 10:04:20 raspberrypi hass[1425896]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jul 11 10:04:20 raspberrypi hass[1425896]:   File "/srv/homeassistant/lib/python3.12/site-packages/pyicloud/services/findmyiphone.py", line 26, in __init__
Jul 11 10:04:20 raspberrypi hass[1425896]:     self.refresh_client()
Jul 11 10:04:20 raspberrypi hass[1425896]:   File "/srv/homeassistant/lib/python3.12/site-packages/pyicloud/services/findmyiphone.py", line 34, in refresh_client
Jul 11 10:04:20 raspberrypi hass[1425896]:     req = self.session.post(
Jul 11 10:04:20 raspberrypi hass[1425896]:           ^^^^^^^^^^^^^^^^^^
Jul 11 10:04:20 raspberrypi hass[1425896]:   File "/srv/homeassistant/lib/python3.12/site-packages/requests/sessions.py", line 637, in post
Jul 11 10:04:20 raspberrypi hass[1425896]:     return self.request("POST", url, data=data, json=json, **kwargs)
Jul 11 10:04:20 raspberrypi hass[1425896]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jul 11 10:04:20 raspberrypi hass[1425896]:   File "/srv/homeassistant/lib/python3.12/site-packages/pyicloud/base.py", line 131, in request
Jul 11 10:04:20 raspberrypi hass[1425896]:     return self.request(method, url, **kwargs)
Jul 11 10:04:20 raspberrypi hass[1425896]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jul 11 10:04:20 raspberrypi hass[1425896]:   File "/srv/homeassistant/lib/python3.12/site-packages/pyicloud/base.py", line 133, in request
Jul 11 10:04:20 raspberrypi hass[1425896]:     self._raise_error(response.status_code, response.reason)
Jul 11 10:04:20 raspberrypi hass[1425896]:   File "/srv/homeassistant/lib/python3.12/site-packages/pyicloud/base.py", line 189, in _raise_error
Jul 11 10:04:20 raspberrypi hass[1425896]:     raise api_error
Jul 11 10:04:20 raspberrypi hass[1425896]: pyicloud.exceptions.PyiCloudAPIResponseException: Authentication required for Account. (450)

Additional information

No response

home-assistant[bot] commented 1 month ago

Hey there @quentame, @nzapponi, mind taking a look at this issue as it has been labeled with an integration (icloud) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `icloud` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign icloud` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


icloud documentation icloud source (message by IssueLinks)

mustbekeene commented 1 month ago

Hi there,

I have just set up an icloud app specific password but find that when using it, the verify code is not sent and there is no resend button. If I reload the app and restart HA I get a verification code send but this is for the prevous time I had the app loaded. I know this becasue on reloading i have to re-enter the password and it wants to resent a verifiaction code which never gets sent.

verify

I hope this makes sense. Cheers Dave

estebanz01 commented 1 month ago

It seems I need to delete the integration and configure it again, which causes issues as it creates tracker entities on every setup. In theory, it should create an entity with an unique ID, no ?

estebanz01 commented 1 week ago

well, now on 2024.08.1 it does not like the app-password so I removed the integration altogether 🤷