Skip to content

Commit

Permalink
feat: minor edits in auth-app instructions for Python (#340)
Browse files Browse the repository at this point in the history
  • Loading branch information
PierrickVoulet authored Nov 19, 2024
1 parent b95b60c commit 9104018
Showing 1 changed file with 16 additions and 24 deletions.
40 changes: 16 additions & 24 deletions python/auth-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This sample demonstrates how to create a Google Chat app that requests authoriza
* **Python 3.7 or higher:** [Download](https://www.python.org/downloads/)
* **Google Cloud SDK:** [Install](https://cloud.google.com/sdk/docs/install)
* **Google Cloud Project:** [Create](https://console.cloud.google.com/projectcreate)
* **Basic familiarity with Google Cloud Console and command line:**
* **Basic familiarity with Google Cloud Console and command line**

## Deployment Steps

Expand All @@ -24,15 +24,14 @@ This sample demonstrates how to create a Google Chat app that requests authoriza
* Enable the Google Chat API: [Enable Chat API](https://console.cloud.google.com/flows/enableapi?apiid=chat.googleapis.com)

```bash
gcloud services enable \
datastore.googleapis.com people.googleapis.com chat.googleapis.com
gcloud services enable datastore.googleapis.com people.googleapis.com chat.googleapis.com
```

2. **Create OAuth Client ID:**
* In your Google Cloud project, go to [APIs & Services > Credentials](https://console.cloud.google.com/apis/credentials).
* Click "Create Credentials" > "OAuth client ID".
* Select "Web application" as the application type.
* Add `http://localhost:8080/auth/callback` to "Authorized redirect URIs" for local testing.
* Click `Create Credentials > OAuth client ID`.
* Select `Web application` as the application type.
* Add `http://localhost:8080/auth/callback` to `Authorized redirect URIs` for local testing.
* Download the JSON file and rename it to `client_secrets.json` in your project directory.

3. **Deploy to App Engine:**
Expand All @@ -45,7 +44,7 @@ This sample demonstrates how to create a Google Chat app that requests authoriza
```bash
gcloud app describe | grep defaultHostname
```
* Update `client_secrets.json`: Replace `http://localhost:8080/auth/callback` in "Authorized redirect URIs" with `<hostname from the previous step>/auth/callback`.
* Update `client_secrets.json`: Replace `http://localhost:8080/auth/callback` in `Authorized redirect URIs` with `<hostname from the previous step>/auth/callback`.
* Redeploy the app:
```bash
gcloud app deploy
Expand All @@ -61,38 +60,36 @@ This sample demonstrates how to create a Google Chat app that requests authoriza
--role="roles/datastore.owner"
```

## Configure Google Chat Integration
## Create the Google Chat app

1. **Enable the Google Chat API:** [Enable Chat API](https://console.cloud.google.com/flows/enableapi?apiid=chat.googleapis.com)
2. **Create a Google Chat App:**
* Go to [Google Chat API](https://developers.google.com/chat/api/guides/quickstart/apps-script) and click "Configuration".
* Enter your App Engine app's URL (obtained in the previous deployment steps) as the **HTTP endpoint URL**.
* Complete the rest of the configuration as needed.
* Go to [Google Chat API](https://developers.google.com/chat/api/guides/quickstart/apps-script) and click `Configuration`.
* Enter your App Engine app's URL (obtained in the previous deployment steps) as the **HTTP endpoint URL**.
* Complete the rest of the configuration as needed.
## Interact with the App
* Add the app to a Google Chat space.
* @mention the app.
* Follow the authorization link to grant the app access to your profile.
* Send messages to the app to see your profile information.
* Type "logout" to deauthorize the app.
* Type `logout` to deauthorize the app.
## Run Locally
1. **Set up Service Account:**
* Create a service account with the "Project > Editor" role.
* Download the service account key as a JSON file (`service-acct.json`).
* Create a service account with the `Project > Editor` role.
* Download the service account key as a JSON file (`service-account.json`).
2. **Set Environment Variable:**
```bash
export GOOGLE_APPLICATION_CREDENTIALS=./service-acct.json
export GOOGLE_APPLICATION_CREDENTIALS=./service-account.json
```
3. **Create Virtual Environment (Recommended):**
```bash
python3 -m venv venv
source venv/bin/activate
python3 -m venv env
source env/bin/activate
```
4. **Install Dependencies:**
Expand Down Expand Up @@ -130,8 +127,3 @@ curl \
}' \
http://127.0.0.1:8080/
```
## Troubleshooting
* **`SpooledTemporaryFile` Error:** If you encounter an error related to the `SpooledTemporaryFile` class, replace `from tempfile import SpooledTemporaryFile` with `from tempfile import TemporaryFile` in `lib/werkzeug/formparser.py`.
* **Other Errors:** Refer to the [Google Chat API documentation](https://www.google.com/url?sa=E&source=gmail&q=https://developers.google.com/chat/api/guides/overview) and [App Engine documentation](https://cloud.google.com/appengine/docs) for troubleshooting and common issues.

0 comments on commit 9104018

Please sign in to comment.