Drakulix / googlehome

Google Home Integration for Home-Assistant
Apache License 2.0
29 stars 4 forks source link

Login failed with "{'Error': 'BadAuthentication'}" #14

Open djtimca opened 3 years ago

djtimca commented 3 years ago

I removed the integration from Home Assistant as part of testing of my other issue, but when I go back to reinstall / configure the integration again I get a Login filed error in the UI.

I have created a new App Password and it still doesn't work.

I assume some credentials may be cached from a previous installation?

Drakulix commented 3 years ago

I already was pretty certain, that I frequently deleted and re-added the integration during development, but to be extra safe, I just removed and added the integration three times without any issues (with different app passwords).

I guess this issue related to your general connection problems with this integration #11.

djtimca commented 3 years ago

It looks like it is related, just not sure which is causing which. I managed to set something up locally and I am getting back {'Error': 'BadAuthentication'} from the get_master_token call. Based on the open issues in gpsoauth it looks like this is something that has come up periodically and nobody has nailed down where it comes from. Going to try a few other things to see if I can't diagnose options.

Drakulix commented 3 years ago

Upstream issues: https://github.com/rithvikvibhu/GHLocalApi/issues/54 https://github.com/simon-weber/gpsoauth/issues/24

arunoruto commented 3 years ago

I am also unable to login with my apppassword and tried multiple things. I tried the functions on my windows machine and the master token is retrieved so it seems like there is a problem with the system on the Pi. Would it maybe be possible to add an additional field while setting it up? Optionally one can also provide a master token directly and skip the master token retrieval for now.

EDIT: I came up with a quick way of bypassing the problem. Maybe you find the pull request useful: #16

Edo78 commented 3 years ago

I'm having the same issue but it's not clear how to obtain the master token

arunoruto commented 3 years ago

I'm having the same issue but it's not clear how to obtain the master token

Sorry, I totally neglected that part, since I was a bit familiar with that part from the past. I was using this simple script to retrieve the master token: https://gist.github.com/rithvikvibhu/952f83ea656c6782fbd0f1645059055d @Drakulix should I make a quick update to the readme or do you want to do it?

Drakulix commented 3 years ago

I'm having the same issue but it's not clear how to obtain the master token

Sorry, I totally neglected that part, since I was a bit familiar with that part from the past. I was using this simple script to retrieve the master token: https://gist.github.com/rithvikvibhu/952f83ea656c6782fbd0f1645059055d @Drakulix should I make a quick update to the readme or do you want to do it?

Sure, make a PR for the readme, if you want, to explain the situation a bit better. But the readme already links here anyway.

QkulleQ commented 3 years ago

Thanks, I have it working by retrieving a master token with this script! :D However I had to do this to get gpsoauth installed:

apk add gcc apk add libc-dev pip install gpsoauth

Not sure if relevant, but here is my configuration: Home Assistant Version: 2020.12.1 Installation Type: Home Assistant OS Python Version: 3.8.6 Operating System Family: Linux Operating System Version: 5.4.86 Host Operating System: Home Assistant OS 5.10 Supervisor Version: 2020.12.7 Docker Version: 19.03.13 Board: intel-nuc

Drakulix commented 3 years ago

Since my authentication code and the linked script are almost identical, I suspect, that maybe the uuid.getnode-function (used to query the systems mac-address to generate a device id) might not yield a good result in some cases (or rather produces an ID, that is not accepted by google).

I noticed this, when I saw @QkulleQ is running Hassio, which means Home-Assistant is running in docker (where getnode would return a locally administered mac-address, that is very docker-specific).

Maybe @Edo78, @SoulEater45 and @djtimca could also post their setups? Primarily operating system and if they use any containerization?

Running the script on a different system (or not in a container) would in those cases result in another ID, which would explain, why the workaround with the script is generating a usable master_token, while the integration fails to do so automatically. If that is indeed the case, I could try to come up with a different generation scheme to fix this.

djtimca commented 3 years ago

I am running Supervised Docker on Ubuntu 20.04

Edo78 commented 3 years ago

I'm on a docker installation of HA Core

arunoruto commented 3 years ago

I am running HassOS on a Raspberry Pi 4

Drakulix commented 3 years ago

Alright, so we have only docker instances so far with this problem, which is a strong indication for my theory. I will try to work on an alternative authentication method / id generation. Maybe that will fix the problem. Be sure to subscribe to this issue, if you want to help with testing.

cicero200272 commented 3 years ago

I am facing this issue as well and also run HA Core in Docker.

Krojack commented 3 years ago

I also got failed login when inputting my Google account UN and using a generated app password. I ended up having to use that script to get a Master Token. Because I was running the script from my Ubuntu server I had to install the app "Device ID" on my phone to get a device ID and also input that within the python script. Got the Master Token and put that in along with the username and app password. It worked.

nvx commented 3 years ago

It looks like a new version of gpsoauth is out with some fixes that might help here. Latest seems to be 0.4.3, while 0.4.1 is in the manifest.

Drakulix commented 3 years ago

It looks like a new version of gpsoauth is out with some fixes that might help here. Latest seems to be 0.4.3, while 0.4.1 is in the manifest.

Thanks for the heads-up! Those are some good news, I will release a patch version with a bumped gpsoauth-version-requirement soon. Hopefully this issue will be solved then for good. (I will of course leave the workaround working until this is confirmed.)