Skip to content

Commit e43f218

Browse files
liminwdpebot
authored andcommitted
Updates to Google ID token service-to-service auth sample (GoogleCloudPlatform#674)
1 parent 72c5467 commit e43f218

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

appengine/flexible/endpoints/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,8 @@ The client project is running Google App Engine standard application.
160160

161161
To use the client for authentication:
162162

163-
1. Update the `google_id_token`'s audiences, replace `YOUR-SERVER-PROJECT-ID` with your server project ID.
164-
2. Redeploy your server application.
165-
3. Update clients/service_to_service_google_id_token/main.py, replace 'YOUR-CLIENT-PROJECT-ID' and 'YOUR-SERVER-PROJECT-ID' with your client project ID and your server project ID.
166-
4. Upload your application to Google App Engine by invoking the following command. Note that you need to provide project ID in the command because there are two projects (server and client projects) here and gcloud needs to know which project to pick.
163+
1. Update clients/service_to_service_google_id_token/main.py, replace 'YOUR-CLIENT-PROJECT-ID' and 'YOUR-SERVER-PROJECT-ID' with your client project ID and your server project ID.
164+
2. Upload your application to Google App Engine by invoking the following command. Note that you need to provide project ID in the command because there are two projects (server and client projects) here and gcloud needs to know which project to pick.
167165
```bash
168166
$ gcloud app deploy app.yaml --project=YOUR-CLIENT-PROJECT-ID
169167
```

appengine/flexible/endpoints/clients/service_to_service_google_id_token/main.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
from google.appengine.api import app_identity
2525
import webapp2
2626

27-
DEFAUTL_SERVICE_ACCOUNT = "YOUR-CLIENT-PROJECT-ID@appspot.gserviceaccount.com"
27+
SERVICE_ACCOUNT_EMAIL = "YOUR-CLIENT-PROJECT-ID@appspot.gserviceaccount.com"
2828
HOST = "YOUR-SERVER-PROJECT-ID.appspot.com"
29-
TARGET_AUD = "YOUR-SERVER-PROJECT-ID@appspot.gserviceaccount.com"
29+
TARGET_AUD = "https://YOUR-SERVER-PROJECT-ID.appspot.com"
3030

3131

3232
def generate_jwt():
@@ -42,11 +42,10 @@ def generate_jwt():
4242
"iat": now,
4343
# expires after one hour.
4444
"exp": now + 3600,
45-
# iss is the Google App Engine default service account email.
46-
"iss": DEFAUTL_SERVICE_ACCOUNT,
47-
# scope must match 'audience' for google_id_token in the security
48-
# configuration in your swagger spec.
49-
"scope": TARGET_AUD,
45+
# iss is the service account email.
46+
"iss": SERVICE_ACCOUNT_EMAIL,
47+
# target_audience is the URL of the target service.
48+
"target_audience": TARGET_AUD,
5049
# aud must be Google token endpoints URL.
5150
"aud": "https://www.googleapis.com/oauth2/v4/token"
5251
})

appengine/flexible/endpoints/swagger.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ paths:
7676
# Your OAuth2 client's Client ID must be added here. You can add
7777
# multiple client IDs to accept tokens from multiple clients.
7878
- "YOUR-CLIENT-ID"
79-
- "YOUR-SERVER-PROJECT-ID@appspot.gserviceaccount.com"
8079
"/auth/info/firebase":
8180
get:
8281
description: "Returns the requests' authentication information."

0 commit comments

Comments
 (0)