Skip to content

Latest commit

 

History

History
79 lines (61 loc) · 3.5 KB

README.md

File metadata and controls

79 lines (61 loc) · 3.5 KB

google-assistant-oauth

Docker Image CI

Simple utility wrapped in Docker image for retrieving the OAuth 2.0 tokens for access to Google Assistant Service.

Get support

Bugs and questions related to the source code and Docker image can be reported at Github Issues in the ismarslomic/google-assistant-oauth repo.

About

In order to access the Google Assistant Service you need to retrieve access and refresh tokens by using Google OAuth2 implementation, this is explained in Google Authorization and Authentication documentation .

This utility simplifies going through the OAuth2 flow and was created in the context of implementing embedded Google Assistant for broadcasting message to Google Assistant enabled speakers, see ismarslomic/google-assistant-broadcast .

Setup

Prerequisites

  • docker - you need to have Docker installed on your machine, read Get Docker for more information.
  • Google OAuth 2.0 Client ID - in order to authenticate yourself and get access to your Google Assistant.
    • Follow steps 1-5 in Configure an Actions Console project
    • Make sure that you choose "Device registration" when creating new project in Actions Console
    • !Important! Download the OAuth Client file from GCP Console / API & Services / Credentials page (not from Google Actions Console), read solution on issue #7. Make also sure that the Application type of the OAuth Client is Desktop
    • Rename the downloaded file from client_secret_****.apps.googleusercontent.com.json to client_secret.json

Run docker container with docker run

Replace /home/pi/config with full path to the folder where your client_secret.json file is located.

Warning To avoid write permission issues inside container, please use a folder with ownership of the OS user you are logged in with. Typically /home/pi on RPI or /home/ubuntu on Ubuntu.

When docker container is terminated and the OAuth2 flow finished, you will find tokens.json file produced in the same folder.

docker run --rm \
-p 3005:3005 \
-v /home/pi/config:/usr/src/config \
ismarslomic/google-assistant-oauth:latest

Click on the URL provided in the console output from the Docker container.

Example of expected client_secret.json file

{
  "installed": {
    "client_id": "****.apps.googleusercontent.com",
    "project_id": "you-project-id",
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://oauth2.googleapis.com/token",
    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
    "client_secret": "****",
    "redirect_uris": [
      "http://localhost"
    ]
  }
}