Get tokens for Google Home Foyer API
Intro
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)
Usage
# Install python requirements
pip install gpsoauth
# Update the constants at the beginning of the file
# Get the tokens!
python3 get_tokens.py
I couldn't get this to work in any version of Linux I had on hand, but I did finally get it to run in Windows.
This is what I did (in PowerShell 7.3.4 in Windows):
Here's my version list:
Details that would help me if I need this info again:
USERNAME
variable had the@gmail.com
omitted, so it was just the portion left of the @-symbol.PASSWORD
variable was an Application-Specific Password (ASP
), created at https://myaccount.google.com/apppasswords for the account.-
).Python 3.11.2 (tags/v3.11.2:878ead1, Feb 7 2023, 16:38:35) [MSC v.1934 64 bit (AMD64)] on win32
, which looks like it was installed viawinget install Python.Python.3.11