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

Allow for multiple Google Accounts and an optional master token login #5

Merged
merged 3 commits into from
Jan 16, 2024

Conversation

jtholen001
Copy link
Contributor

Background

Came across this component, and i hope you're open to additional features/people contributing.

I was having some similar issues to those who were posting in #2 and i believe it has to do with google rejecting auth attempts depending on the device. So i implemented a master token flow to allow for users to get the token manually and be able to login for these "problematic" accounts.

New Features/Updates

  1. Master token config flow
  • Allow for accounts that cannot login with a username password combo to provide a master token acquired from other means. Master token will be preferred login for those who enter it, but will be ignored if a password is provided instead.
  • I also made both password and the master token fields optional but throw an error if they try to add a service without either filled out.
  1. Multiple accounts via new services
  • Updated the code to allow for multiple google accounts to be used in parallel. Google home requires voice match to be setup to add notes to keep via google home. This means for people who have many members in their household that each account needs to be authenticated unfortunately. This allows people like me to be able to add each account when calling the service from automatons.

@jtholen001 jtholen001 mentioned this pull request Dec 12, 2023
@jtholen001
Copy link
Contributor Author

I'm also open if you're cool with it to provide some blueprints for people who are interested in learning more. I use this to connect to anylist from google home actually and this kicks off the import into HA which i have an automation to then delete the todos and add into anylist.

@fcastilloec
Copy link
Owner

Thanks so much for the contribution, this has been on my list but I haven't had the time to do it.
I'll review your code this weekend and merge if no changes are needed.

I'm not too familiar with blueprints; I've never found one that I needed and I always prefer to know the details of how things are done, rather than this black box that blueprints are. I'll be open to them, I just need to understand how these blueprints can be done, and if it's a good idea to host them in this same repo. Feel free to open another PR where we can talk more about that

@fcastilloec
Copy link
Owner

fcastilloec commented Dec 27, 2023

Just wanted to give you an update so you don't think I forgot about this. Holidays have been busy, but this is still on my to-do list, as soon as I have free time, I'll get this reviewed and merged.

@FragMenthor
Copy link

FragMenthor commented Dec 29, 2023

Well, after more than a year, and after finnaly managed to get the master token (really painfull for me), I got the integration to work with this branch, great job!!!
I think it's still not possible with the current state of the "todo lists" in home assistant, but I would like to keep the items in the original list as well (this is a "sync" integration, not a "move" integration), will this eventually be possible? To compare the items in one list and the other and maintain in both (gkeep & todolists)? The integration would have to check for repeated items, I think... That would also alow to add an item in HA, and when the service is called it would be sincronized in GoogleKeep.
What are your opinions on this @fcastilloec and @jtholen001 ?
Thanks!!!

@jtholen001
Copy link
Contributor Author

Well, after more than a year, and after finnaly managed to get the master token (really painfull for me), I got the integration to work with this branch, great job!!! I think it's still not possible with the current state of the "todo lists" in home assistant, but I would like to keep the items in the original list as well (this is a "sync" integration, not a "move" integration), will this eventually be possible? To compare the items in one list and the other and maintain in both (gkeep & todolists)? The integration would have to check for repeated items, I think... That would also alow to add an item in HA, and when the service is called it would be sincronized in GoogleKeep. What are your opinions on this @fcastilloec and @jtholen001 ? Thanks!!!

It’s probably possible but I don’t need this feature personally so I’m not planning on adding it.

@fcastilloec
Copy link
Owner

I original was planning on making this integration sync both ways but it's extremely complicated because Home Assistant didn't have a way to store the item ID and timestamps, so there was no way to check if an item should be deleted or added when found only on either side.
With the new lists integration, this should be possible (I haven't dive into the details but given that other services are syncing, I can't imagine why this wouldn't be able to). It would create its own list rather than sync with the Shooping List one. This is not really and issue, but requieres a rewrite of the code.

Nonetheless, as @jtholen001 said, I also don't need this, so it's not likely that it'll get implemented soon.

@FragMenthor
Copy link

FragMenthor commented Jan 2, 2024

I original was planning on making this integration sync both ways but it's extremely complicated because Home Assistant didn't have a way to store the item ID and timestamps, so there was no way to check if an item should be deleted or added when found only on either side. With the new lists integration, this should be possible (I haven't dive into the details but given that other services are syncing, I can't imagine why this wouldn't be able to). It would create its own list rather than sync with the Shooping List one. This is not really and issue, but requieres a rewrite of the code.

Nonetheless, as @jtholen001 said, I also don't need this, so it's not likely that it'll get implemented soon.

Can I add as a "feature request"? I can envision several benefits with this approach, and I am pretty sure more people will ask / need / beg for for this feature. I understand you do not need this, but as an exemple, I have been teaching my family to use the Google Shopping List, then I must tell them to stop using it and start using Google Keep, and now I tell them not to use Google Keep, only use Home Assistant, knowing that I still don't have an automation to assure that the list is updated on time when I add items through Google Home with voice commands. WAF going wayyyy down.... lol
Maybe someone else can pick this feature request?

@shwarnock
Copy link

Just wanted to chime in, I pulled this branch and followed the readme to get the master token and was able to authenticate with google keep

Copy link
Owner

@fcastilloec fcastilloec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for being so late in reviewing this. The code is good, but I do need to make some changes. Now that multiple lists can be added, we need to set a unique ID for each entry, so there aren't duplicate entries for the same account and list (multiple list from the same account are allowed).
I also don't want to put the "Authentication Options" section directly on the README. I'm going to move it to a Wiki page. This is mainly so people don't use the docker option first.

I'm going to merge this PR as-is and fix all the grammar/spelling and other issues in another PR, before realeasing a new version.

@fcastilloec fcastilloec merged commit ab7c144 into fcastilloec:main Jan 16, 2024
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 this pull request may close these issues.

4 participants