This script (python 3) generates tokens that can be used when making requests to the Google Home Foyer API. There are 2 kinds of tokens used here:
- Master token - Is in the form
aas_et/***
and is long lived. Needs Google username and password. - Access token - Is in the form
ya29.***
and lasts for an hour. Needs Master token to generate.
If you do not want to store the Google account password in plaintext, get the master token once, and set it as an override value.
It's safer/easier to generate an app password and use it instead of the actual password. It still has the same access as the regular password, but still better than using the real password while scripting. (https://myaccount.google.com/apppasswords)
# Install python requirements
pip install gpsoauth
# Update the constants at the beginning of the file
# Get the tokens!
python3 get_tokens.py
ive tried this on my windows computer & live on the raspberry HA system.
always i get an "BadAuthentication",
On the https://myaccount.google.com/apppasswords page my app password is displayed (Called: "HomeAssistant") but it has never been retrieved, so apparently it fails already at the general call.
I have tested the following:
Username: my.email@gmail.com (Fake-Address)
Username: my.email (fake address)
Password: My real password
Password: My app password
I have played through all constellations, apparently the script fails directly on execution / before login.
Here are my examples, various constellations (commented out and censored)