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 gives invalid auth w/ app-specific pw #53926

Open
jkrall opened this issue Aug 4, 2021 · 97 comments
Open

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

jkrall opened this issue Aug 4, 2021 · 97 comments
Assignees

Comments

@jkrall
Copy link
Contributor

jkrall commented Aug 4, 2021

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
Copy link

icloud documentation
icloud source
(message by IssueLinks)

@probot-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!
(message by CodeOwnersMention)

@Salvora
Copy link

Salvora commented Aug 4, 2021

same here, app password doesn't work.

@N3rdix
Copy link
Contributor

N3rdix commented Aug 5, 2021

same for me

@MattLParker
Copy link

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

@shivindera
Copy link

Bump!

@shailyglobal83
Copy link

shailyglobal83 commented Aug 10, 2021

i am facing the same issue.

Any update on same

@shailyglobal83
Copy link

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
Copy link

same here

@pauly7300
Copy link

pauly7300 commented Aug 30, 2021

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
Copy link

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
Copy link
Contributor

Same issue on 2021.9.1

Error in logs:

Error logging into iCloud service: ('Invalid authentication token.', PyiCloudAPIResponseException('Missing apple_id field'))

@thomasfr
Copy link

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

@dsfaller
Copy link

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
Copy link

Thanks for the update

@ushroff
Copy link

ushroff commented Sep 27, 2021

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
Copy link

I have the same issue too...

@Andavin
Copy link

Andavin commented Oct 10, 2021

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

@dsfaller
Copy link

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
Copy link

bad news..
thanks any way....

nlhomme added a commit to nlhomme/home-assistant.io that referenced this issue Nov 30, 2021
As said by @dsfaller in the below issue, Apple changed the login flow or rejects app-specific passwords completely now:
home-assistant/core#53926 (comment)
@github-actions
Copy link

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.

@github-actions github-actions bot added the stale label Jan 17, 2022
@rasmusbe
Copy link
Contributor

still an issue

@github-actions github-actions bot removed the stale label Jan 17, 2022
@caseyjmorton
Copy link

OK. I'm done waiting on someone else more qualified to fix this. I will jump in and see what I can to to fix it myself. For those of you familiar with Major League, just call me Pedro Serrano. I will start working on PRs for all of this. If anyone has any tribal knowledge on this that they can share to help me get started in the right direction, it would be much appreciated. I cant promise a quick or complete solution, but apparently I'm all we got :)

@wolph
Copy link
Contributor

wolph commented May 27, 2024

OK. I'm done waiting on someone else more qualified to fix this. I will jump in and see what I can to to fix it myself. For those of you familiar with Major League, just call me Pedro Serrano. I will start working on PRs for all of this. If anyone has any tribal knowledge on this that they can share to help me get started in the right direction, it would be much appreciated. I cant promise a quick or complete solution, but apparently I'm all we got :)

I've got no clue who major League is but I wish you a lot of luck!

The issue is unfortunately a very difficult one to solve. Apple has no public API available so your only option to do this without the emails is using (or emulating) an apple device which is non-trivial to say the least. Apple really doesn't want 3rd parties to use their private APIs so it's really hard to get that path working.

As I see it you have a few options:

  1. Having a dedicated Apple device which is remote controlled to fetch this information
  2. Having a virtual apple device which is remote controlled. Not sure what the current state is but I know there was a time that a homebrewed apple device could access the APIs
  3. Reverse engineer the Apple authentication to spoof having a real apple device. This one is probably prohibitively difficult to achieve, but if the homebrew option works than you could try this method.

@vajonam
Copy link

vajonam commented May 27, 2024

There is already working HACS icloud integration that works great. https://github.com/gcobb321/icloud3. This integration is dead I won't wast any time on this. Just my $0.02.

@caseyjmorton
Copy link

Understood. Having looked at the HACS one, consider my previous rant retracted.

@caseyjmorton
Copy link

@wolph It looks like someone else has done the real legwork and gone far beyond in a separate project. I guess, I'm just going to migrate to that one as I suggest everyone else who comes across this thread do as well.

I've got no clue who Major League is but I wish you a lot of luck!

Its a 1980's movie about American baseball. I'm honestly not sure how well the humor translates, but IMHO one of the funniest movies of all time. The exact line referenced is "I say F you, Jobu! I'll do it myself!" Its definitely worth a stream.

@magicus
Copy link
Member

magicus commented May 27, 2024

With that said, the icloud3 integration is very "heavy" and comes with a GUI that does not fit with Home Assistant, in contrast to this integration. If it would work, I would switch back from icloud3 right away.

Basically all the fixes that makes icloud3 work resides in changes to the pyicloud library, which this integration also uses. Unfortunately the original author of pyicloud has virtually abandoned the project, so it has not been updated upstream for a long time, but instead several patched version has appeared in different projects.

I started looking at what changes icloud3 had done to the pyicloud library. Unfortunately, the author of icloud3 have made some drastic refactorings that make it really hard to track what is going on. But I'm trying, from time to time, to spend a bit of time getting closer to untangle that mess, to see which changes are really made. I am pretty confident that some of these changes holds the key to getting this integration working again.

Ideally, pyicloud would get a new maintainer and all these patches could be upstreamed to it.

@vajonam
Copy link

vajonam commented May 27, 2024

@wolph It looks like someone else has done the real legwork and gone far beyond in a separate project. I guess, I'm just going to migrate to that one as I suggest everyone else who comes across this thread do as well.

Just follow the docs, and you will be good. with v3 its been made a lot simpler to setup.

@traindriverrev
Copy link

So I was using the legacy system with account password to get in. Latest update forced app specific password. Yay I thought hadn’t even kept up to date that this was even an option.

And suddenly I’m here.

@bmcdonnell-zz
Copy link

Third base. I'm a bit confused why an integration that hasn't worked in 3 years is kept in HomeAssistant year after year for new folks to step in when trying to connect to iCloud

@pacsabi
Copy link

pacsabi commented Jul 13, 2024

It used to work for me (with the monthly deletion of iCloud folder and then again with the adding integration method), but now it doesn't. Of course, I may be doing something wrong, because the documentation is not fixed, there is no mention of an app specific password

@PatrikNorrgard
Copy link

PatrikNorrgard commented Jul 29, 2024

Followed docs, still ended up here with App specific password:

Error logging into iCloud service: ('Invalid authentication token.', PyiCloudAPIResponseException('Missing apple_id field'))

Most recent Home Assistant (2024.7.3)

Also deleted .storage/icloud - didn´t help.

@jacky-coke
Copy link

Same here:
deleted the integration, /config/.storage/icloud-folder and started again from scratch with the same result:

image image

Any suggestions?

@Salvora
Copy link

Salvora commented Jul 29, 2024

@jacky-coke switch to HACS icloud integration. This one is broken for a long time now.
I wonder why this still exists. If it ain't working and no one is working on it to make it work, just remove it from the core.

@pacsabi
Copy link

pacsabi commented Aug 1, 2024

Still Invalid authentication token

@ahass-thedev
Copy link

This issue was resolved before by removing app-specific passwords and using account password. This is now once again asking for app specific password and is returning the error.

@xhighway
Copy link

Using account password instead of requested "one-time password" goes through to 2fa but once 2fa code is submitted it shows "Invalid flow specified" error. But the result is working integration.

@iamrellah
Copy link

I don't seem to get this working either.

Error logging into iCloud service: ('Invalid authentication token.', PyiCloudAPIResponseException('Missing apple_id field'))

Core
2024.9.0
Supervisor
2024.09.0
Operating System
13.0
Frontend
20240904.0

@sehangel
Copy link

sehangel commented Sep 8, 2024

same here, not working.

@sjanssen15
Copy link

Same issue here, should be removed after all this time from HA.
Version: 2024.9.3 (Docker)

@ryan408
Copy link

ryan408 commented Oct 7, 2024

As @xhighway pointed out, if you ignore that it is asking for an app-specific password and use your iCloud password instead you will be prompted to complete 2fa. Once that's done the integration appears to work as expected. So the confusing part is that the dialog while setting up the integration asks for an app-specific password where your iCloud account password works instead.

@ahass-thedev
Copy link

I would not say it works as expected. Apple will eventually timeout the HA login after some time and will reprompt you to setup again and provide 2FA since Apple sees HA as just another device logging into your Icloud. That is why app-specific passwords are needed, it is a one time setup and tells Apple it is not a machine but an app that is allowed to use your account as needed.

@AlexF090
Copy link

I am still encountering the same issue as described in this thread. Despite using an app-specific password and multiple attempts to reinstall and log into the iCloud integration, the authentication fails.

Response on login attempt: While I receive a 200 OK status code, the response still includes "errors": { "password": "invalid_auth" }, indicating an authentication issue.

Full Response:

{
    "type": "form",
    "flow_id": "myFlowID",
    "handler": "icloud",
    "data_schema": [
        {
            "type": "string",
            "name": "username",
            "required": true,
            "default": "MyMail"
        },
        {
            "type": "string",
            "name": "password",
            "required": true,
            "default": "myPassword"
        },
        {
            "type": "boolean",
            "name": "with_family",
            "optional": true,
            "default": false
        }
    ],
    "errors": {
        "password": "invalid_auth"
    },
    "description_placeholders": null,
    "last_step": null,
    "preview": null,
    "step_id": "user"
}

System Setup:

  • Core: 2024.10.4
  • Supervisor: 2024.10.3
  • Operating System: 13.2
  • Frontend: 20241002.4

It appears the issue may not be with the credentials themselves, but potentially due to another restriction within the iCloud integration or API.

@domemshur
Copy link

I am dealing with this too.

@saihaynes
Copy link

me too :(

@marooors
Copy link

Same problem here

@jondrover
Copy link

#metoo

@ahass-thedev
Copy link

@AlexF090 You are getting invalid_auth because the integration is prompting you for app-specific passwords (which is the correct approach) but it is actually authenticating using your actual Icloud password.

Once you use your Icloud password you will be granted access until Apple times you out.

So this integration's issues are:

  1. prompting the user for app-specific passwords but authenticating via user credentials
  2. This in turn leads to timeout issues and constant reauthenticating which is annoying especially since most use 2FA.

Would be helpful if the owner of the integration @Quentame would chime in since this integration has changed under the hood a couple of times since this was posted back in 2021 with no mention in release notes or updates in the tickets.

Thanks.

@ounyai
Copy link

ounyai commented Oct 30, 2024

I cannot authenticate through either App Password or iCloud password - even after removing the iCloud folder in .storage and restaring. Have tried all the combinations. Would appreciate any assistance you can provide - thanks @Quentame

@magicus
Copy link
Member

magicus commented Oct 30, 2024

This integration has been broken for a long time, but right now it is doubly so, since Apple has changed their login methodology. Even iCloud3 (an external component) is struggling to get it to work again, see gcobb321/icloud3_v3#341.

This is likely to be the final nail in the coffin for the built-in integration, since it relies on a python library (pyicloud) that has not been updated for a long time, and which seems completely stalled. The corresponding issue in the original library, picklepete/pyicloud#456, has not seen any feedback at all from the original maintainer. This means that even if a solution is found for this library, it is unlikely to get integrated, and thus usable for the HA iCloud integration.

Sorry folks.

It would have been nice if the non-working integration was actually removed from Home Assistant, but that does not seem to happen. I have pinged the integration owners @Quentame and @nzapponi repeatedly, but they seem to have abandoned the integration. I have tried pinging higher-up responsible developers (like @balloob and @frenck) to get the integration removed, or new active maintainers assigned, but to no avail. :-(

My best recommendation is to move to iCloud3; it is not pretty (and right now it is also broken), but at least it is actively maintained.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests