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

Unknown Error Occurred #2

Closed
ethanblom opened this issue Sep 24, 2023 · 31 comments · Fixed by #3
Closed

Unknown Error Occurred #2

ethanblom opened this issue Sep 24, 2023 · 31 comments · Fixed by #3

Comments

@ethanblom
Copy link

I’ve installed the integration, but when I go to submit the configuration info, I get a “Unknown Error Occurred” message.

@fcastilloec
Copy link
Owner

Hi there, I wasn't expecting anybody to use this integration besides myself. I'm a noob when writing Home Assistant integrations, I know some basic Python but usually for scripting, so this whole repository is probably not top-notch.
I can help figure out what's happening, but not sure how much help I can be.

When do you see that error? Have you been able to go throw the config flow? Please enable logging, I did add some error messages to the code, so logging is the best way to go.

@ethanblom
Copy link
Author

ethanblom commented Sep 24, 2023 via email

@fcastilloec
Copy link
Owner

The error "BadAuthentication" happens because your username or password is wrong. It can also happen because you're using two-factor authentication and this integration doesn't support it.
I suggest you create an app password for this integration and try again. It might fix your issue.
Here's a guide on how to create an app password if you're not familiar with it: Sign in with app passwords

FYI, I think you removed the link to the image you uploaded, so it can't be seen. Try editing your message and re-adding it, and keep the link that GitHub generates when you add the image.

@ethanblom
Copy link
Author

I tried signing in with the app password prior to this as well, but I tried it again to be sure, and I'm still getting the same "unknown error" message and same log error.

@fcastilloec
Copy link
Owner

I really don't know what's going on. From the error message, I think this is coming from the gkeepapi module that we use to contact Google Keep.
Maybe it has something to do with kiwiz/gkeepapi#144
If the problem is with app passwords, if you want to test, you can disable two-factor authentication temporarily and sign in using your actual password. This integration doesn't store your password in any way, once you're logged in, we retrieve a token and use that to login in future attempts. Of course, remember to re-enable two-factor afterward.
I'm going to start the developing environment again and see what's happening, it'll take some time. I haven't done the configuration flow in a really long time, because once you have that token, everything works seamlessly.

I could also create a small Python script that uses gkeepapi and will ask for your username and password and check if everything is working correctly. That way, you don't have to temporarily disable two-factor authentication. I'm a little busy at the moment, so it'll take a while before I get back to you.

@fcastilloec
Copy link
Owner

fcastilloec commented Sep 25, 2023

I also found this issue kiwiz/gkeepapi#81 that looks similar to what you're seeing. I know Home Assistant recently upgraded their Python version and it might be the reason why this is not working. Maybe, I could modify the code to accept a token instead of a password, and the problem should be fixed. This will make it so that you will have to run a separate script to generate this token, which requires the user to have Python installed. I also see that a Docker container can be used, which is probably the best way to make sure dependencies are met and nothing weird happens, and of course means that the user has to have Docker installed.
I can also look into Docker and the script (probably a script that uses Docker is the best way), but it'll take a long time before something functionally gets into this repo.

You could install an old version of Home Assistant, probably 2022.09 or maximum 2022.11, run the config (which should work), and then update Home Assistant.

@ethanblom
Copy link
Author

Thank you for the suggestions. I tried disabling two-factor authentication as well as installing a few different old versions of Home Assistant and I'm still getting the same error message.

@mistikdonbass
Copy link

I also get an authorization error.

fcastilloec , your integration will be very useful!!!

@fcastilloec
Copy link
Owner

Because this issue depends on the kiwiz/gkeepapi#144 to be fixed, I can only do a partial workaround.
My thoughts right now are to change the login process to accept an access token in addition to a password (either of them, not both). That way we bypass the login error. Each user will have to find a way to get their access token. I'll probably provide instructions on how to do it, using https://github.com/rcdeoliveira/gkeepapi-docker seems to work according to people on the original gkeepapi issue. Nonetheless, retrieving the access token will be outside of the scope of this integration because of the gkeepapi issue.

@fcastilloec
Copy link
Owner

@mistikdonbass @ethanblom can you guys test the new commits?
After some searching, I've found other projects affected by the same bug and they've solved it by pinning old versions of some dependencies. I tested the new dependencies on the dev branch of Home Assistant core and it's working without an issue and there's no need to retrieve a master token by users.

@mistikdonbass
Copy link

mistikdonbass commented Nov 1, 2023

Does gkeepapi have to be installed? Now I don’t have it installed, there is an authorization error.

@fcastilloec
Copy link
Owner

@mistikdonbass gkeepapi is installed automatically under Home Assistant, it's a dependency of this integration and you don't have to worry about it.
You don't have to do anything different, just follow the instructions on how to install this integration (see README.md).
If you already had it installed, you should eventually get the update automatically, or you can force an update (check documentation on how to do that online).

@ethanblom
Copy link
Author

I've updated the integration and tried using an app password, as well as turning off 2-step verification, but with both ways I continue to get a Bad Authentication error.

@fcastilloec
Copy link
Owner

I'm sorry but I can't replicate this anymore. Having a fresh installation of Home Assistant, with only this integration enabled, and everything works as it should. Here's a video of the integration running on said fresh installation of Home Assistant.

Segmented_video.mp4

@ethanblom
Copy link
Author

What should I be using for the username in this configuration? I assumed it was the username (@gmail.com email address) that I would typically use to sign into my google keep account. I notice that you didn't use an email address in the video you shared, am I doing this step incorrectly?

@fcastilloec
Copy link
Owner

fcastilloec commented Nov 2, 2023 via email

@ethanblom
Copy link
Author

I've tried my username without the @gmail.com part and that didn't seem to work either. I wonder what I'm doing wrong. Any troubleshooting suggestions you have for me since it seems to be working on your end and not on mine?

@mistikdonbass
Copy link

Screenshot_20231102_212542
Screenshot_20231031_221502
I also get the error, both with and without @gmail.com

@mistikdonbass
Copy link

Maybe we are missing some components?

@fcastilloec
Copy link
Owner

fcastilloec commented Nov 2, 2023

I don't know what's happening. I've tried using a Google account that doesn't have 2-step verification (using the actual password) and it works. I've tried using another account with 2-step enabled and an app password. I've tried with and without the @gmail.com

Can you check your logs? If nothing is showing there, maybe enable logging for everything, eventually, something meaningful will show.
If you had the integration previously configured, remove it, restart Home Assistant (not a quick reload), re-download the integration, and try again. Maybe the old libraries and modules were still loaded and Home Assistant needs to restart to unload them and use the new ones.

@ethanblom
Copy link
Author

I tried completely removing the gkeep_list_sync folder from my custom_components folder, fully restarting Home Assistant, redownloading the new gkeep_list_sync folder from github and placing in custom_components folder, fully restarting Home Assistant, but I am still seeing the error.

@cdrfun
Copy link

cdrfun commented Nov 2, 2023

I'm also having this problem:
2023-11-02 21:08:40.012 ERROR (MainThread) [custom_components.gkeep_list_sync.config_flow] Login error: ('BadAuthentication', None)

I tried using the username with and without @gmail.com and the app password with and without spaces. It all results in the same error.

@jtholen001
Copy link
Contributor

For those still having issues i opened up a pr (#5 ) for a possible workaround that should help. Assuming @fcastilloec is open to contributors this is what allowed me to get a pretty neat workflow working

@viprapp
Copy link

viprapp commented Dec 28, 2023

For those still having issues i opened up a pr (#5 ) for a possible workaround that should help. Assuming @fcastilloec is open to contributors this is what allowed me to get a pretty neat workflow working

I tried your fork utilizing the master token method and it works fine for me.
I would prefer more secure approaches but i guess it's the best we have at the moment.

@jtholen001
Copy link
Contributor

Agreed, it’s far from ideal considering the access this token has, but for some reason Google seems to have checks against the device that affects certain accounts. The only way I am able to get a master token personally is by spinning up a docker container and running some cli commands like I posted in my pr. Super weird for sure.

@FragMenthor
Copy link

FragMenthor commented Dec 28, 2023 via email

@fcastilloec fcastilloec pinned this issue Dec 29, 2023
@jtholen001
Copy link
Contributor

I tried multiples times, and I didn't manage to get a master token. Is there a "easy" way?

_____________ Pedro Roque Em qui., 28 de dez. de 2023 22:06, jtholen001 @.> escreveu:
Agreed, it’s far from ideal considering the access this token has, but for some reason Google seems to have checks against the device that affects certain accounts. The only way I am able to get a master token personally is by spinning up a docker container and running some cli commands like I posted in my pr. Super weird for sure. — Reply to this email directly, view it on GitHub <#2 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARWS4BJIN4M3A6ZF3U5YZ2TYLXUM5AVCNFSM6AAAAAA5ESWAVGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZRGUZDAMRQHE . You are receiving this because you are subscribed to this thread.Message ID: @.
>

If you go to this link (it’s my new code I still have in review) I updated the docs to call out how to get the master token only if you cannot login with an app password.

@alexschwantes
Copy link

Shouldn't this issue be marked as opened as it is still being investigated?

@ethanblom
Copy link
Author

When I try to get the master token I get the following result:
image

Any suggestions on why it is unable to retrieve the master token?

@fcastilloec
Copy link
Owner

There's a new version of this integration based on the work of @jtholen001 (Thanks for your contribution!) 🥳

The new version can accept passwords or tokens, and it also allows you to add multiple lists (from the same or different accounts). This can be helpful if multiple people have their own "Shopping" lists, and all of them will get merged into Home Assistant.

Regarding the docker container to retrieve a Master Token. Please direct any questions to @jtholen001, he kindly provided the code to work, but support it is beyond the scope of this project.

@alexschwantes
Copy link

There is another repo that now supports google keep - > HA todo, multi user, multi list, event notifications here. https://github.com/watkins-matt/home-assistant-google-keep-sync
There is also a guide on obtaining the token if you can't login.

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

Successfully merging a pull request may close this issue.

8 participants