问题
I tried to follow the documentation and got stuck in the point
- Open a terminal and follow the instructions to configure a new Python virtual environment and install the `google-assistant-library.
The link in this point redirects to a general page (Introduction to the Google Assistant Library) rather than the instructions. I think it misses the explanation what it means to open the terminal and exact steps to be followed. Is the link really correct?
Maybe I need help in using the console correctly, but I am not getting it from that poor documentation. I can connect to RP with Serial to USB cable and Putty. But simply I do not know what that point 11 and onwards mean... Any idea? Thank you
回答1:
It looks like the links in the Assistant SDK docs were modified, but it should be pointing to this page:
sudo apt-get update
sudo apt-get install python3-dev python3-venv # Use python3.4-venv if the package cannot be found.
python3 -m venv env
env/bin/python -m pip install --upgrade pip setuptools
source env/bin/activate
python -m pip install --upgrade google-auth-oauthlib[tool]
google-oauthlib-tool --scope https://www.googleapis.com/auth/assistant-sdk-prototype \
--save --headless --client-secrets /path/to/client_secret_client-id.json
This will save the credentials at /path/to/.config/google-oauthlib-tool/credentials.json
, which you can then copy into your project in order to authenticate the Google Assistant.
回答2:
As Nick and proppy noted, one step is to obtain authorization code to be used in later steps. Unfortunately the documentation skipped few very important steps and it can lead to confusion. Sadly Google did not simplify the process of integrating the Assistant in the same development environment and hope they will integrate this clumsy process to Android Studio as with other services
If you are developing under Windows you need to:
- use a Linux environment and follow the steps in console of that Linux PC (not in the Android Things console of the RP!). Or install Python in Windows. I used the Raspbian in my RP3 to do the Linux version of the procedure...
- install Python environment first in the Linux PC console
sudo apt-get update sudo apt-get install python3-dev python3-venv python3 -m venv env env/bin/python -m pip install --upgrade pip setuptools source env/bin/activate
- in this Python environment install google-auth-oauthlib that will generate the credential file
python -m pip install --upgrade google-auth-oauthlib[tool]
- change the directory to place you saved the downloaded json file from step before step 11 in the documenatation. e.g.
cd /home/pi/Downloads/
- run the google auth tool with the path to your downloaded json file (including its long name, replace idxxx with your id)
google-oauthlib-tool --client-secrets /home/pi/Downloads/client_secret_client-idxxx.json --scope https://www.googleapis.com/auth/assistant-sdk-prototype --save --headless
there will be a link generated in the console. You have to insert the link into browser . You will be prompted in browser to let the tool to use your account and the you will receive an authentication code. Enter this code to the prompt back in the console.
find the generated authenticated authorization code file in the folder prompted in the console and continue in the original documentation steps
来源:https://stackoverflow.com/questions/48448844/google-assistant-on-rpi3-with-android-things