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.47k stars 29.4k forks source link

ICloud integration gives invalid auth w/ app-specific pw #53926

Open jkrall opened 3 years ago

jkrall commented 3 years ago

The problem

I'm attempting to setup the iCloud integration w/ an app-specific password, per the instructions here.

Upon hitting submit, I get a short spinner and then "Invalid authentication" — and I cannot proceed beyond this error to finish setting up the icloud integration. I've also tried the suggested troubleshooting step of removing the .storage/icloud directory, to no avail. (which is created upon attempting to setup the integration, but removing it has no affect on the issue)

I have confirmed that I've entered the app-specific password correct, and attempted several different passwords I've generated on appleid.apple.com.

What is version of Home Assistant Core has the issue?

core-2021.7.4

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/#app-specific-passwords

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2021-08-03 23:05:32 ERROR (SyncWorker_40) [pyicloud.base] Missing apple_id field
2021-08-03 23:05:32 ERROR (MainThread) [homeassistant.components.icloud.config_flow] Error logging into iCloud service: ('Invalid authentication token.', PyiCloudAPIResponseException('Missing apple_id field'))

Additional information

No response

probot-home-assistant[bot] commented 3 years ago

icloud documentation icloud source (message by IssueLinks)

probot-home-assistant[bot] commented 3 years 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! (message by CodeOwnersMention)

Salvora commented 3 years ago

same here, app password doesn't work.

N3rdix commented 3 years ago

same for me

MattLParker commented 3 years ago

same: these occur in logs Error logging into iCloud service: ('Invalid authentication token.', PyiCloudAPIResponseException('Missing apple_id field'))

shivindera commented 3 years ago

Bump!

shailyglobal83 commented 3 years ago

i am facing the same issue.

Any update on same

shailyglobal83 commented 3 years ago

i am waiting for this issue to get resolve ASAP because my presence detection automation is completely blocked because of that issue .Please respond if there is any update regarding this issue. Thanks in advance.

tommekevda commented 3 years ago

same here

pauly7300 commented 2 years ago

I'm experiencing the same running 2021.8.8. Both with my actual icloud pw as well as app specific pw. I've also tried with 2 separate icloud accounts. Additionally i've spun up multiple VM's to try and isolate all other factors and have even downgraded Core to 2021.7.x which is where I had it running last but even that doesn't seem to work. My assumption was the the version of Core was potentially the issue but now I'm wondering if the integration itself has a 'version' that isn't manageable within the context of HA itself and potentially that is the issue. I've spent quite a bit of time trying to isolate this and can't figure out what is different...

The specific behavior for me is after entering my un/pw on the below screen, I get the Apple prompt immediately asking to allow a login. I proceed to the 6 digit code dialog but the dialog below just spins continuously for a very long time and i never get prompted to enter the code.

2021-08-30_13-34-07
david-schwartz-by commented 2 years ago

I have the same experience as @pauly7300

I'm experiencing the same running 2021.8.8. Both with my actual icloud pw as well as app specific pw. I've also tried with 2 separate icloud accounts. Additionally i've spun up multiple VM's to try and isolate all other factors and have even downgraded Core to 2021.7.x which is where I had it running last but even that doesn't seem to work. My assumption was the the version of Core was potentially the issue but now I'm wondering if the integration itself has a 'version' that isn't manageable within the context of HA itself and potentially that is the issue. I've spent quite a bit of time trying to isolate this and can't figure out what is different...

The specific behavior for me is after entering my un/pw on the below screen, I get the Apple prompt immediately asking to allow a login. I proceed to the 6 digit code dialog but the dialog below just spins continuously for a very long time and i never get prompted to enter the code.

<img alt="2021-08-30_13-34-07" width="468" src="https://user-images.githubusercontent.com/11494052/131388098-1df4ba36-513f-4ce4-8cff-b9648103beff.png"

sarabveer commented 2 years ago

Same issue on 2021.9.1

Error in logs:

Error logging into iCloud service: ('Invalid authentication token.', PyiCloudAPIResponseException('Missing apple_id field'))
thomasfr commented 2 years ago

Same issue, same error, same logs here on latest HAOS with latest Core, Supervisor versions. Can I help somehow to fix it?

dsfaller commented 2 years ago

Same issue here with app-specific password... I played a little bit with the underlying code samples of pyiCloud (https://github.com/picklepete/pyicloud) and the sample code showed the same error when using my AppleID / app-specific password... raising a ticket there and hoping that the developer will react.

thomasfr commented 2 years ago

Thanks for the update

ushroff commented 2 years ago

I'm experiencing the same running 2021.8.8. email address and password are accepted. But verification code is accepted and constantly rejected by the iCloud integration app. Logger: homeassistant.components.icloud.config_flow Source: components/icloud/config_flow.py:272 Integration: Apple iCloud (documentation, issues) First occurred: 2:11:28 AM (2 occurrences) Last logged: 2:11:37 AM

Failed to verify verification code: (401)

mada199122 commented 2 years ago

I have the same issue too...

Andavin commented 2 years ago

Is there going to be a resolution for this? It seems as though this hasn't been noticed by a developer

dsfaller commented 2 years ago

I did more digging with the underlying pyicloud library (see comment in my issue there) - seems like pyicloud is emulating to be a web browser and not using any official API. Apparently, Apple changed the login flow or rejects app-specific passwords completely now - in any case the library no longer receives the necessary login tokens to work. My conclusion is that we need a rewrite of pyicloud for app-specific passwords or another library for the icloud plugin in Home Assistant... :(

mada199122 commented 2 years ago

bad news.. thanks any way....

github-actions[bot] commented 2 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

rasmusbe commented 2 years ago

still an issue

eappels commented 2 years ago

Same for me, still can't login using the app specific pw, getting Invalid authentication error. In the logs: 2022-01-18 09:08:43 ERROR (SyncWorker_3) [pyicloud.base] Missing apple_id field 2022-01-18 09:08:43 ERROR (MainThread) [homeassistant.components.icloud.config_flow] Error logging into iCloud service: ('Invalid authentication token.', PyiCloudAPIResponseException('Missing apple_id field'))

OlafKocanda commented 2 years ago

same here :( even deleting the .storage/icloud/ folder and restarting did not work

vajonam commented 2 years ago

this is not being actively worked on, don't' expect any fixes. I have abandoned this integration, should be marked broken IMHO.

JBMedeiros commented 2 years ago

same here :( even deleting the .storage/icloud/ folder and restarting did not work

Same here.

thenoid commented 2 years ago

Same as everyone else :( give app specific passwords unto me!

wolph commented 2 years ago

I've had a little dive into this, and it seems completely impossible to use app-passwords the way it's currently setup. The icloud integration uses the icloud web interface and the web interface does not appear to support app passwords.

I'm not sure if apple actually exposes the "find my" api through regular means. If they do, it might be possible to completely rewrite this but I'm expecting that they do not support 3rd party access to "find my".

JuhaFIN1 commented 2 years ago

Any news for this? Here same, dosent work anymore and icloud forder + restart dont help even :(

medivb commented 2 years ago

I have the same issue as well. Way beyond my league to even consider fixing it, but it would really be appreciated!

fredR142 commented 2 years ago

I am also having this problem, I have tried resetting my apple id password on an iphone and again ( different password ) on my pc , but nothing works ! Still get the missing apple id field response . Oh and this is not using the app password

philippe-tc commented 1 year ago

Still not working with Apple application specific password, unfortunately.

Is any news to be expected? Anybody working on rewriting the code? Unfortunately I can’t be of any help, not able to write any useful code here.

wolph commented 1 year ago

Still not working with Apple application specific password, unfortunately.

Is any news to be expected? Anybody working on rewriting the code? Unfortunately I can’t be of any help, not able to write any useful code here.

I wouldn't expect a solution to be honest. It's highly likely that it's completely impossible to use an app password for this purpose.

vajonam commented 1 year ago

This integration should be removed and marked as broken. Seems too hard to keep it going using the current methods. Until Apple allows API access to find my functionality.

wolph commented 1 year ago

I disagree. While it has a few issues it largely works for me and is quite convenient to have. And much more reliable than the home assistant ios app since that one requires being opened at a regular interval.

jpaulamaki commented 1 year ago

Seems to be an issue for me as well; as long as I log in with the regular password, I get the linkage going just fine, but no dice with the app specific passwords.

I'm not really a developer by any reasonable yardstick, but I have a black belt in googling odd stuff out, and it seems that the issue is that Apple is not allowing the app-specific passwords to be used in browser sessions...

...and this plugin is doing exactly that, logging in as a browser session. I'm not a detective either, just a regular Columbo, only with better hair - but I'd say that the email alert in my inbox saying "Your Apple ID was used to sign in to iCloud via a web browser" is a 🤏 wee bit of a smoking gun in that direction.

So: someone who knows how to code, maybe has coded / maintains this extension or something, ought to migrate to using Apple's API login methods instead of trying to work through the browser login path.

grave176 commented 1 year ago

I solved the problem by installing it with my Apple ID and password. After 2FA number it is installed. Then removed the apple id integration and added it again with the One time password and it worked for me.

vajonam commented 1 year ago

I would recommend folks with 2FA try https://gcobb321.github.io/icloud3/#/

It takes a bit more RTFM to setup. But just works better than this integration.

magicus commented 1 year ago

Does iCloud3 provide the "play sound" system call? That's what I mainly use this integration for, to locate my (or my kids...) phone when lost in the sofa or wardrobe or whatever.

N3rdix commented 1 year ago

I believe yes, this should be possible. Reading the docs often helps, it’s very well maintained: https://gcobb321.github.io/icloud3/#/chapters/3.4-services

vajonam commented 1 year ago

Yes this works so well!

newkton1 commented 1 year ago

Could icloud3 be retasked as standard core integration rather than force users to jump thru the HACS hoops?

magicus commented 1 year ago

I'm currently in the process of replacing the standard icloud integration with icloud3. It is not really a smooth ride. Apparently icloud3 is much more capable, but that also means turning a lot more knobs to get it to work. Get me right, I love the kind of add-ons that gives you the full power to tweak anything, but for a default option in HA, there need to be a simple to use solution that solves most cases with good defaults.

I think icloud3 would need some work to get there, possibly splitting it in two, one simplified version to put in HA core, and one separate with full power. If the icloud3 developer(s) support this, I think it would be great, but it might not be painless for icloud3.

In fact, for me, the standard icloud solution was kind of perfect, except for the slightly annoying fact that it stopped working.

So an alternative is to just see what icloud3 does differently in terms of authentication, and copy that over to the standard icloud integration. Possibly it's just a more up-to-date fork of pyicloud (pyicloud_ic3.py).

newkton1 commented 1 year ago

It would be great if somebody could take on this task because the standard iCloud integration is badly broken.

LewisSpring commented 1 year ago

I think icloud3 would need some work to get there, possibly splitting it in two, one simplified version to put in HA core, and one separate with full power. If the icloud3 developer(s) support this, I think it would be great, but it might not be painless for icloud3.

I share the same complaints as everyone else. I've put off setting up iCloud3 multiple times, even though I've had so many issues with the stock integration, because iCloud3 is very complicated to setup and I have a hard time following the docs.

I'd very much appreciate something like this being proposed to HASS developers/iC3 developer.

magicus commented 1 year ago

I started looking at the current code, to check for differences to what iCloud3 does, and if it would be possible to just replace the standard pyicloud implementation with the fork from iCloud 3. I still think this is a viable way forward, keeping most of the current functionality of the standard iCloud integration, but borrowing bits and pieces from iCloud 3 to get it to work.

Unfortunately, it would require more time than I can spend at this at the moment. :-( Is there anyone else around here who has some python and/or HA knowledge and would be willing to work on this? I can probably put down a few hours but that in itself is not likely to be enough. But maybe it could be a start that someone can continue working on..?

ADXGlock commented 1 year ago

I solved the problem by installing it with my Apple ID and password. After 2FA number it is installed. Then removed the apple id integration and added it again with the One time password and it worked for me.

This workaround worked for me as well. I deleted the cloud addon folder, signed in w/ normal password and then removed the integration and re-added it with app specific password.

magicus commented 1 year ago

@ADXGlock and @grave176 Has it stayed working since then? Or did the password expire after a month, and you had to redo everything again?

bcutter commented 1 year ago

@ADXGlock and @grave176 Has it stayed working since then? Or did the password expire after a month, and you had to redo everything again?

@ADXGlock + @grave176

emce commented 1 year ago

Any progress here? I also got tired with amount of login notification emails from iCloud...