I’m super new to all this so hopefully I didnt do something really bad.
The links in this reply either have parentheses around the “h” in “https” or I had to put a space. I’m allowed (2) links apparently, and I’m not quick enough to figure out how to do that the right way.
I’m running proxmox with HA on a separate laptop, and performed the following on a separate laptop used to access the HA OS GUI.
I followed the instructions (Google Assistant SDK - Home Assistant) and clicked around aimlessly until I stumbled upon something that seems to work.
After downloading the “client_secrets_XXXXX…json” file from Google Cloud Console and renaming it (remember the directory), I needed to run the “google-oauthlib-tool.”
I’ve never used Python for Windows (using win10), but I downloaded it and eventually realized that you need to be sure Windows Terminal can use it. So I wrote “python --version” in the command line, and it came back with an error or nonsense.
In order to make it work, I had to go to System Properties → Advanced System Settings → Environment Variables.
From that screen, look under “System Variables” and find “Path.”
Click “Edit” button, then click “New” on the next screen to add a new path for windows to use to find the Python code (I guess?), then enter the directory where you installed Python (mine was C:\Users.…\AppData\Local\Programs\Python\Python312)
Then, be sure to hit “OK” on all the boxes before opening a new Terminal window.
Type your “python --version” command and you should see something like (directory redacted below but that’s the command and result):
C:\Users.…>python --version
Python 3.12.3
I then ran the Python code: “python -m pip install --upgrade google-auth-oauthlib[tool]” but received some weird errors in Terminal warning about something or other.
Anyway, turns out I had to go back into the “Environment Variables → System Variables - Path” screen and add a New directory to the path shown on warning screen (for me, the folder missing from Path was “scripts” so I hit “New” then pasted in C:\Users.…\AppData\Local\Programs\Python\Python312\Scripts)
NOW, I actually got something to happen after restarting Terminal and using the command:
pip --version (Windows Terminal command and output below):
C:\Users.…>pip --version
pip 24.0 from C:\Users.…\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip (python 3.12)
So I have Python and Pip running, so now I could run (Windows Terminal) to paste:
google-oauthlib-tool --scope (h)ttps://www.googleapis.com/auth/assistant-sdk-prototype --scope (h)ttps://www.googleapis.com/auth/gcm --save --client-secrets %userprofile%\Downloads\client_secret.json
-----OR------
python -m pip install --upgrade google-auth-oauthlib[tool]
Well, all’s well and a browser popped open but no dice…turns out this redirect_uri is OOB or something
Google error: (h)ttps://developers.google.com/identity/protocols/oauth2/web-server#authorization-errors-redirect-uri-mismatch
Finally, after screwing around, I changed the command to include the path to the “clients_secret.json” file
(Change %userprofile% to whatever your path is. Mine was like C:\Users\Downloads\client_secret.json)
But still no dice.
Finally, I clicked a link on the Google error page:
If you are a developer of this app, see [error details]
(http ://accounts.google.com/)
which brought me to a popup:
Error 400: redirect_uri_mismatch
You can’t sign in to this app because it doesn’t comply with Google’s OAuth 2.0 policy.
If you're the app developer, register the redirect URI in the Google Cloud Console.
Request details: redirect_uri=http://localhost:8080/
[Related developer documentation]
(h ttps://developers.google.com/identity/protocols/oauth2/web-server#authorization-errors-redirect-uri-mismatch)
Done
Welp, I figured that if it was a misdirect then maybe, just maybe, I could go back into Cloud Console and add another Authorized Redirect URL under that particular name. So mine just redirects the oauthlib tool back to my HA server:
(Under Google Cloud Console → Credentials (left bar) → Oauth 2.0 Client IDs (pick the one you used originally to set up Google-assistant-sdk):
(Please note the lack of “h” in “https”; apparently I put too many links but I dont know how to un-hyperlink in this forum):
Authorized redirect URIs
For use with requests from a web server
URIs 1
‘ttps://my.home-assistant.io/redirect/oauth’
URIs 2
‘ttp://localhost:8080/’
Lo and behold, a browser popped up, asked me to allow access and all that jazz, and now here I am explaining it poorly.
If you can follow that gibberish, maybe you can find your own way.
Good luck out there, and please let me know if I’ve opened my home up to let just anyone turn on and off my lights.