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
I tried a lot. get latest python v3.12.0 installed. run pip install gpsoauth - Ok. copy text of get_tokens.py raw text, saved to my pc. Change username to my google username full email address. password section, tried with app password generated by Google security. (note: it is 16 chars. google displayed with 4 sets with space in between. I tried with space or without). Even I turned off google 2 way auth method, so I can use my google password instead. I always get "Could not get master token", "Master token:None" , "Could not get access token", "Access token:None" don't know why? Anyone can help?