I’m trying to embed google assistant SDK on my raspberry pi by following this guide by Google. However I’m stuck at configuring the Oauth2 credentials in the generate credentials step of the guide.
I installed the google-auth-oauthlib[tool]
package to be able to run google-oauthlib-tool
. When I run the ran the tool as explained in the guide, I get the following error:
$ google-oauthlib-tool --scope https://www.googleapis.com/auth/assistant-sdk-prototype
--save --headless --client-secrets /path/to/client_secret_client-id.json
Error: no such option: --headless
(PS. I adapted the –client-secrets path to the correct json file I downloaded from google projects API credentials page)
When I remove the --headless
option from the command, the tool produces an authorization URL as expected. I can go to the URL, sign into my google account and activate the necessary permissions. Next, I get a google ‘site unreachable’ page as it is referring me to a URL starting with localhost:8080/...
. From the full url I can extract the needed 4/...
code to finalize the authorization process… In theory as I then noticed the google-oauthlib-tool
never asked me for the authorization code in the terminal. It just shows an empty line but it should say (according to step 4):
Enter the authorization code:
Does anyone know how why google-oauthlib-tool
never asks the Authorization code? It might have something to do with the missing --headless
option but I don’t know enough about this whole Oauth2 process.
I’ve tried force-reinstalling all involved tools but that didn’t solve the problem.
session info:
-
python 3.9.2
-
pip 23.0.1
-
google-auth-oauthlib 1.0.0
-
linux kernel: Linux 6.1.21-v8+ aarch64
-
OS: Debian GNU/Linux 11 (bullseye)
-
platform: Raspberry pi 4B
2
Answers
I found the answer to my own question but I'll leave this post up for future reference.
background: I went looking into around what 'headless' actually means (pretty basic for most of you probably). It refers to 'headless client', aka, an application/OS running without GUI (Graphic User Interface). Basically, only the command line. Thus, I realized I installed the GUI version of the raspberry pi OS instead of the lite version. The google guide probably assumed I was running a headless client.
solution: Instead of remote connecting to my raspberry pi over ssh, I directly opened the command line from the device itself through the GUI and ran the
google-oauthlib-tool
without the--headless
option. Then thelocalhost:8080/...
link worked and it created the credentials file on my device.Solution that worked for me with non-GUI raspberry PI:
-download screen "sudo apt-get screen"
-execute screen -S auth
-execute source env/bin/activate
-execute google-oauthlib-tool –scope
https://www.googleapis.com/auth/assistant-sdk-prototype –save –client-secrets /path/to/client_secret_client-id.json
Modify the command to match the secret file
-Complete authentication on any device using chrome
-At this state, you should see a failed to load website page
-open chrome dev tools(F12)
-go to network
-reload the webpage
-on the entry that popped up, click copy-> format curl(bash)
-on raspberry pi, press "Ctrl+a" and afterward "d" to close the screen
-paste in terminal