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
Hi all, likely a python issue but most of what I have seems correct. Error below which is "ModuleNotFoundError: No module named 'gpsoauth'" however pip freeze shows the module is there. Any ideas?
(test1234) PS C:\Users\george> python3 get_token.py
Traceback (most recent call last):
File "C:\Users\george\get_token.py", line 5, in
from gpsoauth import perform_master_login, perform_oauth
ModuleNotFoundError: No module named 'gpsoauth'
(test1234) PS C:\Users\george> pip freeze
certifi==2023.5.7
charset-normalizer==3.2.0
gpsoauth==1.0.2
idna==3.4
pycryptodomex==3.18.0
requests==2.31.0
urllib3==2.0.3
(test1234) PS C:\Users\george> pip install urllib3<2.0.0
Collecting urllib3<2.0.0
Using cached urllib3-1.26.16-py2.py3-none-any.whl (143 kB)
Installing collected packages: urllib3
Attempting uninstall: urllib3
Found existing installation: urllib3 2.0.3
Uninstalling urllib3-2.0.3:
Successfully uninstalled urllib3-2.0.3
Successfully installed urllib3-1.26.16
(test1234) PS C:\Users\george> pip freeze
certifi==2023.5.7
charset-normalizer==3.2.0
gpsoauth==1.0.2
idna==3.4
pycryptodomex==3.18.0
requests==2.31.0
urllib3==1.26.16
(test1234) PS C:\Users\george>