Go to the GCloud Installation Page and follow the instructions to install the Google Cloud SDK.
Go to the Google Cloud Console and create a new project, note the project name.
export project_name="your-project-name"
- Go to the Google Cloud Console.
- Navigate to the APIs & Services -> Credentials page.
- Create a new OAuth 2.0 Client ID, application type Desktop App.
- Download the client secrets file, and save it as secret/client_secrets.json.
- Go to the Google Cloud Console
- Navigate to the IAM & Admin -> Service Accounts page.
- Create a new service account, and download the JSON key file.
- Save the JSON key file as secret/service_account.json.
This should open a browser window to authenticate with your Google account.
gcloud auth login
gcloud auth application-default login
gcloud config set project $project_name
gcloud services enable chat.googleapis.com pubsub.googleapis.com workspaceevents.googleapis.com
export topic_id="workspace-topic"
export topic_name="projects/$project_name/topics/$topic_id"
export subscription_id="workspace-subscription"
gcloud pubsub topics create $topic_id
gcloud pubsub topics add-iam-policy-binding $topic_name --member='serviceAccount:[email protected]' --role='roles/pubsub.publisher'
gcloud pubsub subscriptions create $subscription_id --topic=$topic_name
- Go to the Google Chat API page.
- Go to Configuration tab.
- Fill in the App name, Avatar URL, and Description.
- Click Enable Interactive Features, check Receive 1:1 messages and Join spaces and group conversations
- For Connection Settings, choose Cloud Pub/Sub and Cloud Pub/Sub Topic Name
- Tick Make this Chat app available to specific people and groups in Global Fashion Group, and add your email.
Go to root directory of the project and run the following commands:
export PYTHONPATH="$(pwd):$PYTHONPATH"
python app/main.py
The application should prompt you to authenticate with your Google account.
If you want to hide your token on a shared machine, you can use a passphrase to encrypt the token. Add a leading space to the command to prevent it from being saved in the history.
PASSPHRASE="your-passphrase" python app/main.py
If it still shows up in the history, try HISTCONTROL=ignorespace
and re-run the command.