You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added three samples:
1. Use App Engine default service account client (without key file).
2. Use non-default service account client (without key file).
3. Use Google ID token client (without key file)
The JWT client demonstrates how to use service accounts to authenticate to endpoints. To use the client, you'll need both an API key (as described in the echo client section) and a service account. To create a service account:
62
+
The JWT client demonstrates how to use a service account to authenticate to endpoints with the service account's private key file. To use the client, you'll need both an API key (as described in the echo client section) and a service account. To create a service account:
63
63
64
64
1. Open the Credentials page of the API Manager in the [Cloud Console](https://console.cloud.google.com/apis/credentials).
65
65
2. Click 'Create credentials'.
@@ -76,7 +76,7 @@ Now you can use the JWT client to make requests to the API:
The ID Token client demonstrates how to use user credentials to authenticate to endpoints. To use the client, you'll need both an API key (as described in the echo client section) and a OAuth2 client ID. To create a client ID:
82
82
@@ -93,3 +93,73 @@ To use the client ID for authentication:
93
93
Now you can use the client ID to make requests to the API:
### Using the App Engine default service account client (no key file needed)
98
+
99
+
The App Engine default service account client demonstrates how to use the Google App Engine default service account to authenticate to endpoints.
100
+
We refer to the project that serves API requests as the server project. You also need to create a client project in the [Cloud Console](https://console.cloud.google.com).
101
+
102
+
To use the App Engine default service account for authentication:
103
+
104
+
1. Update the `gae_default_service_account`'s `x-issuer` and `x-jwks_uri` in `swagger.yaml` with your client project ID.
105
+
2. Redeploy your server application.
106
+
3. Update clients/service_to_service_gae_default/main.py, replace 'YOUR-CLIENT-PROJECT-ID' and 'YOUR-SERVER-PROJECT-ID' with your client project ID and your server project ID.
107
+
4. Upload your application to Google App Engine by invoking the following command under clients/service_to_service_gae_default directory.
108
+
This opens a browser window for you to sign in using your Google account. You'll be providing the project ID as the argument for -A. Use
109
+
the -V argument to specify a version name. Additional information on how to deploy an app to Google Cloud App Engine can be found [here](https://cloud.google.com/appengine/docs/python/quickstart).
110
+
111
+
appcfg.py -A <YOUR-CLIENT-PROJECT-ID> -V v1 update .
112
+
113
+
Your client app is now deployed at https://<YOUR-CLIENT-PROJECT-ID>.appspot.com. When you access https://<YOUR-CLIENT-PROJECT-ID>.appspot.com, your client calls your server project API using
114
+
the client's service account.
115
+
116
+
### Using the service account client (no key file needed)
117
+
118
+
The service account client demonstrates how to use a non-default service account to authenticate to endpoints.
119
+
We refer to the project that serves API requests as the server project. You also need to create a client project in the [Cloud Console](https://console.cloud.google.com).
120
+
121
+
In the example, we use Google Cloud Identity and Access Management (IAM) API to create a JSON Web Token (JWT) for a service account, and use it to call an Endpoints API.
122
+
123
+
To use the client, you will need to enable "Service Account Actor" role for App Engine default service account:
124
+
1. Go to [IAM page] of your client project (https://console.cloud.google.com/iam-admin/iam).
125
+
2. For App Engine default service account, from “Role(s)” drop-down menu, select “Project”-“Service Account Actor”, and Save.
126
+
127
+
You also need to install Google API python library because the client code (main.py) uses googleapiclient,
128
+
which is a python library that needs to be uploaded to App Engine with your application code. After you run "pip install -t lib -r requirements",
129
+
Google API python client library should have already been installed under 'lib' directory. Additional information can be found
1. Update the `google_service_account`'s `x-issuer` and `x-jwks_uri` in `swagger.yaml` with your service account email.
134
+
2. Redeploy your server application.
135
+
3. Update clients/service_to_service_non_default/main.py, replace 'YOUR-SERVICE-ACCOUNT-EMAIL', 'YOUR-SERVER-PROJECT-ID' and 'YOUR-CLIENT-PROJECT-ID'
136
+
with your service account email, your server project ID, and your client project ID.
137
+
4. Upload your application to Google App Engine by invoking the following command under clients/service_to_service_non_default directory.
138
+
This opens a browser window for you to sign in using your Google account. You'll be providing the project ID as the argument for -A. Use
139
+
the -V argument to specify a version name. Additional information on how to deploy an app to Google Cloud App Engine can be found [here](https://cloud.google.com/appengine/docs/python/quickstart).
140
+
141
+
appcfg.py -A <YOUR-CLIENT-PROJECT-ID> -V v1 update .
142
+
143
+
Your client app is now deployed at https://<YOUR-CLIENT-PROJECT-ID>.appspot.com. When you access https://<YOUR-CLIENT-PROJECT-ID>.appspot.com, your client calls your server project API using
144
+
the client's service account.
145
+
146
+
### Using the ID token client (no key file needed)
147
+
148
+
This example demonstrates how to authenticate to endpoints from Google App Engine default service account using Google ID token.
149
+
In the example, we first create a JSON Web Token (JWT) using the App Engine default service account. We then request a Google
150
+
ID token using the JWT, and call an Endpoints API using the Google ID token.
151
+
152
+
We refer to the project that serves API requests as the server project. You also need to create a client project in the [Cloud Console](https://console.cloud.google.com).
153
+
154
+
To use the client for authentication:
155
+
1. Update the `google_id_token`'s audiences, replace `YOUR-SERVER-PROJECT-ID` with your server project ID.
156
+
2. Redeploy your server application.
157
+
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.
158
+
4. Upload your application to Google App Engine by invoking the following command under clients/service_to_service_google_id_token directory.
159
+
This opens a browser window for you to sign in using your Google account. You'll be providing the project ID as the argument for -A. Use
160
+
the -V argument to specify a version name. Additional information on how to deploy an app to Google Cloud App Engine can be found [here](https://cloud.google.com/appengine/docs/python/quickstart).
161
+
162
+
appcfg.py -A <YOUR-CLIENT-PROJECT-ID> -V v1 update .
163
+
164
+
Your client app is now deployed at https://<YOUR-CLIENT-PROJECT-ID>.appspot.com. When you access https://<YOUR-CLIENT-PROJECT-ID>.appspot.com, your client calls your server project API from
165
+
the client's service account using Google ID token.
0 commit comments