-
Notifications
You must be signed in to change notification settings - Fork 280
fix: [Python] Auth App #338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,16 +24,27 @@ please read the | |
| 1. Enable the Cloud Datastore API for your project using | ||
| [this wizard](https://console.cloud.google.com/flows/enableapi?apiid=datastore.googleapis.com). | ||
| 1. Follow [instructions](https://support.google.com/googleapi/answer/6158849?hl=en) for creating | ||
| an oauth client ID for your project. Use the type "Web application" and a redirect | ||
| URI of \ | ||
| `https://<project ID>.appspot.com/auth/callback`. | ||
| an oauth client ID for your project. Use the type "Web application". | ||
| 1. Download the associated JSON file, move it to this directory, and name it | ||
| `client_secret.json`. | ||
| `client_secrets.json`. | ||
|
|
||
| 1. Run the following command to deploy the app: | ||
| ``` | ||
| gcloud app deploy | ||
| ``` | ||
| 1. Fetch the URL: | ||
| ``` | ||
| gcloud app browse | ||
| ``` | ||
| 1. Replace the `redirect_uris` in your `client_secrets.json` with `<URL from the previous step>/auth/callback`. | ||
| 1. Create a [service account](https://support.google.com/a/answer/7378726?hl=en#) | ||
|
||
| 1. Make the service account the default in the [App Engine Application Settings](https://console.cloud.google.com/appengine/settings) | ||
| 1. Grant the service account permissions to access the datastore | ||
| ``` | ||
| gcloud projects add-iam-policy-binding $PROJECT_ID \ | ||
| --member="serviceAccount:$SERVICE_ACCOUNT_EMAIL" \ | ||
| --role="roles/datastore.owner" | ||
| ``` | ||
|
|
||
| ## Configure the app for Google Chat | ||
|
|
||
|
|
@@ -76,7 +87,25 @@ To verify that the sample is running and responds with the correct data | |
| to incoming requests, run the following command from the terminal: | ||
|
|
||
| ``` | ||
| curl -H 'Content-Type: application/json' --data '{"type": "MESSAGE", "configCompleteRedirectUrl": "https://www.example.com", "message": { "text": "header keyvalue", "thread": null }, "user": { "name": "users/123", "displayName": "me"}, "space": { "displayName": "space", "name": "spaces/-oMssgAAAAE"}}' http://127.0.0.1:8080/ | ||
| curl \ | ||
| -H 'Content-Type: application/json' \ | ||
| --data '{ | ||
| "type": "MESSAGE", | ||
| "configCompleteRedirectUrl": "https://www.example.com", | ||
| "message": { | ||
| "text": "header keyvalue", | ||
| "thread": null | ||
| }, | ||
| "user": { | ||
| "name": "users/123", | ||
| "displayName": "me" | ||
| }, | ||
| "space": { | ||
| "displayName": "space", | ||
| "name": "spaces/-oMssgAAAAE" | ||
| } | ||
| }' \ | ||
| http://127.0.0.1:8080/ | ||
| ``` | ||
|
|
||
| ## Shut down the local environment | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,3 +21,5 @@ runtime: python310 | |
| env_variables: | ||
| CLIENT_SECRET_PATH: "client_secret.json" | ||
| SESSION_SECRET: "notasecret" | ||
|
|
||
| service_account: <SERVICE_ACCOUNT> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm assuming that this value needs to be set before deploying, should we add an additional step in the README instructions? Alternatively, you could add a quick comment that define what it is.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated the instructions |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #!/bin/bash | ||
|
|
||
| python3 -m venv .venv | ||
| source .venv/bin/activate | ||
| python3 -m pip install --upgrade -r requirements.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: describe the expected result
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the instructions