From a3376fe241c1f853218ad150a0ba737d2ef4f7ce Mon Sep 17 00:00:00 2001 From: Sai Cheemalapati Date: Tue, 30 Aug 2016 11:53:02 -0700 Subject: [PATCH 1/4] Revert "Temporarily remove some sample features" --- .../endpoints-frameworks-v2/echo/README.md | 15 ++++++++++++++- .../endpoints-frameworks-v2/echo/app.yaml | 6 ++++++ .../standard/endpoints-frameworks-v2/echo/main.py | 4 +++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/appengine/standard/endpoints-frameworks-v2/echo/README.md b/appengine/standard/endpoints-frameworks-v2/echo/README.md index 12e6ddb4282..98d19ef1475 100644 --- a/appengine/standard/endpoints-frameworks-v2/echo/README.md +++ b/appengine/standard/endpoints-frameworks-v2/echo/README.md @@ -2,6 +2,11 @@ This demonstrates how to use Google Cloud Endpoints Frameworks v2 on Google App Engine Standard Environment using Python. +This sample consists of two parts: + +1. The backend +2. The clients + ## Setup Create a `lib` directory in which to install the Endpoints Frameworks v2 library. For more info, see [Installing a library](https://cloud.google.com/appengine/docs/python/tools/using-libraries-python-27#installing_a_library). @@ -23,7 +28,15 @@ In your web browser, go to the following address: http://localhost:8080/\_ah/api ## Deploying to Google App Engine -Deploy the sample using `gcloud`: +Generate a swagger file by running: `endpointscfg.py get_swagger_spec main.EchoApi --hostname your-service.appspot.com` + +To set up OAuth2, replace `your-oauth-client-id.com` under the `x-security` section in `echo-v1_swagger.json` with your OAuth2 client ID. If you want to use Google OAuth2 Playground, use `407408718192.apps.googleusercontent.com` as your audience. To generate a JWT, go to the following address: `https://developers.google.com/oauthplayground`. + +Deploy the generated swagger spec to Google Cloud Service Management: `gcloud alpha service-management deploy echo-v1_swagger.json` + +Open the `app.yaml` file and in the `env_variables` section, replace `your-service.appspot.com` with your service name, and `2016-08-01r0` with your uploaded service management configuration. + +Then, deploy the sample using `gcloud`: $ gcloud beta app deploy diff --git a/appengine/standard/endpoints-frameworks-v2/echo/app.yaml b/appengine/standard/endpoints-frameworks-v2/echo/app.yaml index 1a2d33ebb29..688df0ad9d4 100644 --- a/appengine/standard/endpoints-frameworks-v2/echo/app.yaml +++ b/appengine/standard/endpoints-frameworks-v2/echo/app.yaml @@ -22,3 +22,9 @@ libraries: version: 2.6 - name: ssl version: 2.7.11 + +env_variables: + # Replace with your endpoints service name. + ENDPOINTS_SERVICE_NAME: your-service.appspot.com + # Replace with the version Id of your uploaded Endpoints service. + ENDPOINTS_SERVICE_VERSION: 2016-08-01r0 diff --git a/appengine/standard/endpoints-frameworks-v2/echo/main.py b/appengine/standard/endpoints-frameworks-v2/echo/main.py index 2348e1f6edc..b4d3dad6eb9 100644 --- a/appengine/standard/endpoints-frameworks-v2/echo/main.py +++ b/appengine/standard/endpoints-frameworks-v2/echo/main.py @@ -53,7 +53,9 @@ def echo(self, request): path='echo/getUserEmail', http_method='GET', # Require auth tokens to have the following scopes to access this API. - scopes=[endpoints.EMAIL_SCOPE]) + scopes=[endpoints.EMAIL_SCOPE], + # OAuth2 audiences allowed in incoming tokens. + audiences=['your-oauth-client-id.com']) def get_user_email(self, request): user = endpoints.get_current_user() # If there's no user defined, the request was unauthenticated, so we From f0a1e511bfecc22362ca69cd4920959950e33e1c Mon Sep 17 00:00:00 2001 From: Sai Cheemalapati Date: Tue, 30 Aug 2016 11:55:12 -0700 Subject: [PATCH 2/4] Remove extra doc bits --- appengine/standard/endpoints-frameworks-v2/echo/README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/appengine/standard/endpoints-frameworks-v2/echo/README.md b/appengine/standard/endpoints-frameworks-v2/echo/README.md index 98d19ef1475..da2b8dbfd4e 100644 --- a/appengine/standard/endpoints-frameworks-v2/echo/README.md +++ b/appengine/standard/endpoints-frameworks-v2/echo/README.md @@ -2,11 +2,6 @@ This demonstrates how to use Google Cloud Endpoints Frameworks v2 on Google App Engine Standard Environment using Python. -This sample consists of two parts: - -1. The backend -2. The clients - ## Setup Create a `lib` directory in which to install the Endpoints Frameworks v2 library. For more info, see [Installing a library](https://cloud.google.com/appengine/docs/python/tools/using-libraries-python-27#installing_a_library). From d6cce212f29204783507d7b22b04127e9558fbf9 Mon Sep 17 00:00:00 2001 From: Sai Cheemalapati Date: Tue, 30 Aug 2016 12:10:55 -0700 Subject: [PATCH 3/4] Fix swagger generation command --- appengine/standard/endpoints-frameworks-v2/echo/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appengine/standard/endpoints-frameworks-v2/echo/README.md b/appengine/standard/endpoints-frameworks-v2/echo/README.md index da2b8dbfd4e..17d1b29eeaa 100644 --- a/appengine/standard/endpoints-frameworks-v2/echo/README.md +++ b/appengine/standard/endpoints-frameworks-v2/echo/README.md @@ -23,7 +23,7 @@ In your web browser, go to the following address: http://localhost:8080/\_ah/api ## Deploying to Google App Engine -Generate a swagger file by running: `endpointscfg.py get_swagger_spec main.EchoApi --hostname your-service.appspot.com` +Generate a swagger file by running: `python lib/endpoints/endpointscfg.py get_swagger_spec main.EchoApi --hostname your-service.appspot.com` To set up OAuth2, replace `your-oauth-client-id.com` under the `x-security` section in `echo-v1_swagger.json` with your OAuth2 client ID. If you want to use Google OAuth2 Playground, use `407408718192.apps.googleusercontent.com` as your audience. To generate a JWT, go to the following address: `https://developers.google.com/oauthplayground`. From 39eb47c56d1b5cb1cbe4db29bf540ece69b14489 Mon Sep 17 00:00:00 2001 From: Sai Cheemalapati Date: Tue, 30 Aug 2016 12:13:09 -0700 Subject: [PATCH 4/4] Fix OAuth2 instructions --- appengine/standard/endpoints-frameworks-v2/echo/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appengine/standard/endpoints-frameworks-v2/echo/README.md b/appengine/standard/endpoints-frameworks-v2/echo/README.md index 17d1b29eeaa..d8519f307f5 100644 --- a/appengine/standard/endpoints-frameworks-v2/echo/README.md +++ b/appengine/standard/endpoints-frameworks-v2/echo/README.md @@ -25,7 +25,7 @@ In your web browser, go to the following address: http://localhost:8080/\_ah/api Generate a swagger file by running: `python lib/endpoints/endpointscfg.py get_swagger_spec main.EchoApi --hostname your-service.appspot.com` -To set up OAuth2, replace `your-oauth-client-id.com` under the `x-security` section in `echo-v1_swagger.json` with your OAuth2 client ID. If you want to use Google OAuth2 Playground, use `407408718192.apps.googleusercontent.com` as your audience. To generate a JWT, go to the following address: `https://developers.google.com/oauthplayground`. +To set up OAuth2, replace `your-oauth-client-id.com` under `audiences` in the annotation for `get_user_email` with your OAuth2 client ID. If you want to use Google OAuth2 Playground, use `407408718192.apps.googleusercontent.com` as your audience. To generate a JWT, go to the following address: `https://developers.google.com/oauthplayground`. Deploy the generated swagger spec to Google Cloud Service Management: `gcloud alpha service-management deploy echo-v1_swagger.json`