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

iCloud integration continiously pops MFA approval on all Apple devices #101816

Closed
scaarup opened this issue Oct 11, 2023 · 84 comments · Fixed by #120945
Closed

iCloud integration continiously pops MFA approval on all Apple devices #101816

scaarup opened this issue Oct 11, 2023 · 84 comments · Fixed by #120945
Assignees

Comments

@scaarup
Copy link

scaarup commented Oct 11, 2023

The problem

Every 30 days or so, it seems like the authentication with iCloud expires. I am notified about this in Home Assistant, so I go to my integration and hits reconfigure, enter my password and get "reauth successfull". Now on all my phones, a prompt will appear every 20 minutes, asking if I want to allow a sign-on, and if yes it displays a mfa code.
The integrations seems to be fetching data from iCloud just fine... I cannot make these annoying pop-ups on my phones go away. Even if I disable the integration and reenable it after some days. I am only asked for password, not the mfa code.

What version of Home Assistant Core has the issue?

core-2023.10.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

icloud

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

@home-assistant
Copy link

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.

(message by CodeOwnersMention)


icloud documentation
icloud source
(message by IssueLinks)

@styxxen80
Copy link

I have been experiencing the same issue the last couple of days

@BjornBP
Copy link

BjornBP commented Oct 13, 2023

This has been happening to me for at least a year, probably longer. What is more, the notifications start popping up on my devices many days before the iCloud integration seems to "realise" that it needs to re-authenticate. Consequently, after allowing the authentication on my devices and receiving the authentication code, there is no option to enter this into the integration. So the whole thing repeats until eventually the integration wakes up to the fact that it needs a code.
HA Auth

@scaarup
Copy link
Author

scaarup commented Oct 13, 2023

This has been happening to me for at least a year, probably longer. What is more, the notifications start popping up on my devices many days before the iCloud integration seems to "realise" that it needs to re-authenticate. Consequently, after allowing the authentication on my devices and receiving the authentication code, there is no option to enter this into the integration. So the whole thing repeats until eventually the integration wakes up to the fact that it needs a code.

Exactly the same for me. In the past I have managed to pop the reauth code flow, by disabling and enabling the integration. But after several attempts, I now had to delete and reinstall the integration.

@stuartford
Copy link

stuartford commented Oct 13, 2023

This has started for me too today. Nowhere to enter the code under the integration, and the integration does not seem to believe there is a problem.

@stuartford
Copy link

Update: this was driving me mad, so I deleted the integration. But I am still receiving the MFA requests?!

@mattcharlton
Copy link

Had this happen to me overnight. It woke me up on my watch 3-4 times and has continued to do so this morning.

Quite worrying as it told me the sign in requests were coming from Bristol (I'm in Leeds). Tried to narrow down what it was. Disabled the integration, still got them.

Deleted the integration, then recreated and got the same prompt on login from Bristol so I know it's HA at fault here.

Have deleted the integration for now. Will keep an eye on this bug.

@stuartford
Copy link

@mattcharlton In the end I had to delete the integration and go into the terminal remove the storage folder. It just wasn't going to quit otherwise. I can (and will) live without this integration, but I do hope they fix it. Supporting app passwords (which according to other issues it does not) would put an end to this.

@mattcharlton
Copy link

@stuartford Yeah I've just had another prompt now. Trying a server restart but will have a look at the storage folder now, thank you :)

@mattcharlton
Copy link

iCloud Storage folder gone, hopefully that'll sort it till they fix it. I might have a look around the code in a bit.

@mattcharlton
Copy link

Looks like the 2fa/verification code stuff is hardcoded into the flow. Easiest fix might be to pull all that out and state that you have to use an app specific password with it. Don't have a local test/dev env set up for HA so not in the best position to have a look at this, hopefully the code owners will pick it up soon enough.

@HebeROF
Copy link

HebeROF commented Oct 15, 2023

Had this happen to me overnight. It woke me up on my watch 3-4 times and has continued to do so this morning.

Same for me. Deleted it for now, as even deactivated every 5 to 10 minutes MFA requests arrived on all devices.

@MrHawk93
Copy link

Exactly every 30 minutes I get the notification on my phone, tonight I had to turn off my phone to be able to sleep, I definitely deleted the application

@khammo01
Copy link

I also have this unfortunate issue, probably like everybody else on the planet who is using this. This is critical showstopper, please anyone who knows how, please submit a pull request or something... :-(

@platini76
Copy link

same problem here

@LeFlairGoD
Copy link

Same here

@w1Ngx
Copy link

w1Ngx commented Oct 23, 2023

same, started 2 days ago

@LeFlairGoD
Copy link

Small Workarround from other forum, then is for the time being again silence....

  1. go to iCloud integration
  2. press the 3 dots and choose delete
  3. ssh into home assistant (I use the add-on "Terminal & SSH!"
  4. delete icloud folder
  5. rm -rf /config/.storage/icloud
  6. add your icloud account in the integration again
  7. Now the box will popup for you to put in the verification code.

@MrEbbinghaus
Copy link
Contributor

Apple allows creating app specific passwords https://support.apple.com/102654 instead of using 2FA.

I just removed and readded my account to the integration using such a password.
Since that password doesn't need 2FA, it should solve the problem once and for all.

(Honestly, that should be the default way instead of using your real AppleID password.)

@scaarup
Copy link
Author

scaarup commented Oct 23, 2023

Apple allows creating app specific passwords https://support.apple.com/102654 instead of using 2FA.

I just removed and readded my account to the integration using such a password. Since that password doesn't need 2FA, it should solve the problem once and for all.

(Honestly, that should be the default way instead of using your real AppleID password.)

Ah this is awesome. I have just done the same thing.

@LeFlairGoD
Copy link

Apple allows creating app specific passwords https://support.apple.com/102654 instead of using 2FA.

I just removed and readded my account to the integration using such a password. Since that password doesn't need 2FA, it should solve the problem once and for all.

(Honestly, that should be the default way instead of using your real AppleID password.)

Perfect, that worked. After a reboot all devices were back again! Thank you!

@Beleriond75
Copy link

Apple allows creating app specific passwords https://support.apple.com/102654 instead of using 2FA.

I just removed and readded my account to the integration using such a password. Since that password doesn't need 2FA, it should solve the problem once and for all.

(Honestly, that should be the default way instead of using your real AppleID password.)

Coming into this only now but if I want to enter an app-specific password instead of going the 2FA route, does that mean I have to delete the integration and re-add it again?

Thanks,
Bel*.

@magicus
Copy link
Member

magicus commented Oct 24, 2023

@MrEbbinghaus That is great news! Last time I checked, they did not allow this. (But I must admit it was some time ago...)

The documentation for the iCloud component should be updated to strongly recommend this, both from the security point of view, to getting rid of the 2FA annoyances.

@magicus
Copy link
Member

magicus commented Oct 24, 2023

Also, for the record, here is a direct link for the page which allows you to create app-specific passwords: https://appleid.apple.com/account/manage/section/security

@LeFlairGoD
Copy link

Apple erlaubt die Erstellung anwendungsspezifischer Passwörter https://support.apple.com/102654 anstelle der Verwendung von 2FA.
Ich habe gerade mein Konto mit einem solchen Passwort entfernt und der Integration wieder hinzugefügt. Da dieses Passwort keine 2FA benötigt, sollte es das Problem ein für alle Mal lösen.
(Ehrlich gesagt sollte dies die Standardmethode sein, anstatt Ihr echtes AppleID-Passwort zu verwenden.)

Ich komme erst jetzt dazu, aber wenn ich ein App-spezifisches Passwort eingeben möchte, anstatt den 2FA-Weg zu gehen, bedeutet das, dass ich die Integration löschen und erneut hinzufügen muss?

Danke, Bel*.

That is exactly what it means. After deleting and re-adding, it is best to restart once, only then were all devices in again for me.

@MrEbbinghaus
Copy link
Contributor

@magicus Unfortunately it was followed by bad news a couple of hours later.

The integration wasn't able to communicate with iCloud any more, and I got a "Your password was used to login" mail from Apple every minute until I disabled the integration again.

@stuartford
Copy link

The app password method doesn't work for me, it just returns "Invalid authentication".

@magicus
Copy link
Member

magicus commented Oct 25, 2023

@MrEbbinghaus Oh, that is too bad. :-(

@miles267
Copy link

miles267 commented Mar 7, 2024

Has there been a fix for this yet?

@markus99
Copy link

Also inquiring if an update is planned on this. I'm still needing to re-login (and force reload the integration a few times a week as well) in order to maintain connectivity / updates into HA. Greatly appreciate the work to date and in advance if anyone(s) able to update the authentication mechanism(s) to fix this issue!

@Server131
Copy link

This happens every 60-90 days for me.

  1. Log into iCloud on a browser.
  2. Click on Account (person icon in the top right),
  3. Click on iCloud Settings
  4. Scroll to the bottom "Sign out of all browsers"
  5. Reload the iCloud integration in HA - promps for password & MFA
  6. Restart HA.

The MFA pop-ups & integration warnings go away.

@bkpiaskun
Copy link

Hi,
I'm not sure if this might help, but I can see two separate sessions in my /config/.storage/icloud directory, despite having one registered.
ls in that directory was:

  • pia(redacted)
  • pia(redacted).session
  • Pia(redacted)
  • Pia(redacted).session
    And I was getting MFA logins despite actually having this integration reconfigured.

Deleting one of them fixed this issue for me.
It was the same filename, but one started with capital letter.

@twynne
Copy link

twynne commented May 6, 2024

I'm not entirely sure it's this integration, but things have become far worse since yesterday, with multiple devices constantly prompting for MFA. This continued overnight and seems now to ignore sleep focus. I've disabled the integration, but the prompts keep coming. I'm sure I've seen others note that disabling doesn't work. Is there some way to remove the integration entirely?

@LeFlairGoD
Copy link

I'm not entirely sure it's this integration, but things have become far worse since yesterday, with multiple devices constantly prompting for MFA. This continued overnight and seems now to ignore sleep focus. I've disabled the integration, but the prompts keep coming. I'm sure I've seen others note that disabling doesn't work. Is there some way to remove the integration entirely?

#101816 (comment)

rcmaehl added a commit to rcmaehl/core that referenced this issue Jul 1, 2024
iCloud integration deauths often if not using App Specific Passwords. This spams MFA prompts on all devices and is not a good UX. Swap working to get people to use App Specific Passwords. HA Docs (https://www.home-assistant.io/integrations/icloud/) still need to be updated to reflect this
rcmaehl added a commit to rcmaehl/home-assistant.io that referenced this issue Jul 1, 2024
@warmfire540
Copy link

is this really fixed? the PR looks pretty minimal. I try and use app password and I get Invalid authentication

@stuartford
Copy link

is this really fixed? the PR looks pretty minimal. I try and use app password and I get Invalid authentication

I thought that. Just looks like a field label change. No actual change to functionality.

@OptimusGREEN
Copy link

is this really fixed? the PR looks pretty minimal. I try and use app password and I get Invalid authentication

yeah when i tried an app password last week i got invalid authentication too so not convinced this will be working.

@warmfire540
Copy link

warmfire540 commented Jul 7, 2024

@rcmaehl or @frenck can you reopen this or create a duplicate? This was falsely closed..

@rcmaehl
Copy link
Contributor

rcmaehl commented Jul 7, 2024

@warmfire540 @OptimusGREEN and anyone else having issues can you all confirm that:

  • Your default 2FA/MFA is not currently set to a Security Token when setting up the App-Specific Password?
  • You're using the email selected as "Apple ID" from the Emails & Phone Numbers section of https://appleid.apple.com/account/manage/section/security?
  • You are/have been using an Apple Device signed into the account that is/has connected to the same network as the HomeAssistant host?
  • You're able to sign into https://appleid.apple.com/ from a desktop web browser on the same network as the HomeAssistant host (and ideally create the App-Specific Password within that desktop web browser)?
  • You are polling iCloud no more than once every 60 seconds (I poll every 5 minutes) once setup?

@LeFlairGoD
Copy link

I have done everything as described but I get the error message with the app specific password every time:
Invalid authentication

The login works with my correct password

@warmfire540
Copy link

@rcmaehl yes - same. I'm unsure of the first bullet point - where would I check? I just went into icloud and created app specific pw - get error.

Can you show screenshots or video of it working for you?

@rcmaehl
Copy link
Contributor

rcmaehl commented Jul 9, 2024

I'm going to dig into the pyicloud stuff later today for the setup failures and the issue below where it thinks the extension needs to be reconfigured despite it working. I can confirm that when it does take the App Password that you no longer get MFA spam however.

image
IMG_0484

@warmfire540
Copy link

Ok sounds good! I'm sure the MFA will go away, however it's not accepting my app password - I can't get past that part.

@rcmaehl
Copy link
Contributor

rcmaehl commented Jul 11, 2024

Okay, I tested this with my wife's account.

App-specific password seems to work for reauth but not initial auth. I need to revoke everything and undo some test changes I made to her account to confirm it wasn't something else but current workaround flow seems to be:

  1. Generate App-Specific Password
  2. Initial setup using Account Password including allowing MFA prompt and entering 2FA code
  3. Reload Integration
  4. Deny MFA prompt
  5. Wait a minute or so for the Integration to want re-auth
  6. Enter App-Specific Password

If this does work, I'll submit a patch to adjust the setup workflow

I could have sworn I did the initial setup for my own account with the App-Specific Password but I may be mistaken.

@rcmaehl
Copy link
Contributor

rcmaehl commented Jul 11, 2024

So was able to reproduce initial setup with the app-specific password that worked with my account. Only works if you remove and readd the same iCloud Entry too quickly.

I may be in an extended MFA grace period currently as I'm not getting the MFA prompt when reloading the extension now but as soon as I do I'll retry with the App-Specific password to confirm my previous comment and then we'll go from there.

frenck pushed a commit to rcmaehl/home-assistant.io that referenced this issue Jul 19, 2024
c0ffeeca7 pushed a commit to home-assistant/home-assistant.io that referenced this issue Jul 19, 2024
* Update Docs for App-Specific Passwords

See:
home-assistant/core#101816
home-assistant/core#120945

* Update source/_integrations/icloud.markdown

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* define "it" instead of using bot suggestion

* Update source/_integrations/icloud.markdown

Co-authored-by: Franck Nijhof <frenck@frenck.nl>

* Update source/_integrations/icloud.markdown

Co-authored-by: Rosemary Orchard <16113535+RosemaryOrchard@users.noreply.github.com>

* Advise on solution

* Update source/_integrations/icloud.markdown

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
Co-authored-by: Rosemary Orchard <16113535+RosemaryOrchard@users.noreply.github.com>
austinmroczek pushed a commit to austinmroczek/home-assistant.github.io that referenced this issue Jul 20, 2024
* Update Docs for App-Specific Passwords

See:
home-assistant/core#101816
home-assistant/core#120945

* Update source/_integrations/icloud.markdown

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* define "it" instead of using bot suggestion

* Update source/_integrations/icloud.markdown

Co-authored-by: Franck Nijhof <frenck@frenck.nl>

* Update source/_integrations/icloud.markdown

Co-authored-by: Rosemary Orchard <16113535+RosemaryOrchard@users.noreply.github.com>

* Advise on solution

* Update source/_integrations/icloud.markdown

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
Co-authored-by: Rosemary Orchard <16113535+RosemaryOrchard@users.noreply.github.com>
@LeFlairGoD
Copy link

Hello everyone,
I'm not sure if the problem has been solved or not?
Or has a new problem been opened and I just can't find it?

@calisro
Copy link

calisro commented Aug 15, 2024

No Its not solved. The directions were changed to use app specfic passwords yet they don't work for the majority of users. Although they should probably be used, the integration doesn't work well with adding them.

@warmfire540
Copy link

can anyone confirm @rcmaehl 's latest comment? I rage uninstalled it, but can make a new ticket if OP isn't available anymore

@rcmaehl
Copy link
Contributor

rcmaehl commented Aug 23, 2024

can anyone confirm @rcmaehl 's latest comment? I rage uninstalled it, but can make a new ticket if OP isn't available anymore

I can confirm doing initial setup with Password, and then re-authing with an App Specific Password prevents with Apple MFA pop-up spam and has worked for me for since I made that comment.

I need to rewrite the configuration flow to prompt for both values (should be easy) and then actually use the ASP when reauth is needed (Can figure out but I have no idea how to compile test builds for HomeAssistant to test changes yet)

@github-actions github-actions bot locked and limited conversation to collaborators Sep 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.