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
utilizing the link that @molexx shared, I ended up modifying the docker run slightly so that I could get inside the container to make a few changes to the python itself.
After it created, I did a
docker ps
to find the name of the container (I tried providing a name and it would always fail). Once this was created, I used the following:docker exec -it tender_gates bash
tender_gates
being the name it generated for me, but once running this, I was in the container.I ran
apt install nano
just to make it easier to work with and then rannano get_tokens.py
to open the file. I commented outand replacing it with
After making this change, press
Ctrl + O
and then press enter to Save the changes, then pressCtrl + X
to exit nano.When I ran it in the container by typing
python3 get_tokens.py
, I thought that was going to work but kept getting[!] Could not get master token.
so I decided to changeDEBUG = False
toDEBUG = True
, saved and exited nano again and ran it again and was provided:PROGRESS!! I held down Control and clicked the link which brought me to a browser to finish the authentication process from the web browser to authenticate the script to work. You may have to go through a few prompts (I did) and then it will end up at a page that says
One Moment Please...
, which at this point you can re-runpython3 get_token.py
and it should provide you with a lot more information than just the master and access tokens as DEBUG is still on, but you should be provided with the information needed.Hope this helps someone.