Quickstart for App Engine

This page walks you through deploying an App Engine standard or flexible environment application and securing it with Cloud Identity-Aware Proxy (Cloud IAP). The quickstart includes sample code for an App Engine standard environment web app that verifies a logged-in user's name. This quickstart uses Cloud Shell to clone and deploy the sample application. You can use this quickstart to enable Cloud IAP for your own App Engine standard environment or App Engine flexible environment app.

If you plan to serve resources from a content delivery network (CDN), see the best practices guide for important information.

Before you begin

  1. Sign in to your Google Account.

    If you don't already have one, sign up for a new account.

  2. Select or create a GCP project.

    Go to the project selector page

  3. Make sure that billing is enabled for your Google Cloud Platform project. Learn how to enable billing.

Starting Cloud Shell

  1. Click Activate Cloud Shell at the top of the console window. Activate Cloud Shell

    A Cloud Shell session opens inside a new frame at the bottom of the console and displays a command-line prompt. It can take a few seconds for the shell session to be initialized.

    Cloud Shell session
  2. Enter the following in Cloud Shell to display the project IDs for your projects:
    gcloud projects list
  3. Run the following command to set the default project, where YOUR-PROJECT-ID is the project ID you want to use for this quickstart:
    gcloud config set project YOUR-PROJECT-ID

Getting the sample code

  1. Enter the following command in Cloud Shell to get the sample application:

    git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git
  2. Change to the directory that contains the sample code:

    cd python-docs-samples/appengine/standard/users/

Deploying the application

  1. Use gcloud to deploy the application to App Engine:
    gcloud app deploy
  2. The target url: is displayed in the format https://YOUR_PROJECT_ID.appspot.com. To access your application, navigate to that URL in your web brower.

Enabling Cloud IAP

Selecting a project

  1. Go to the Identity-Aware Proxy page.
    Go to the Identity-Aware Proxy page
  2. If you don't already have an active project, you'll be prompted to select the project you want to secure with Cloud IAP. Select the project to which you deployed the sample application.

Configuring the OAuth consent screen

If you haven't configured your project's OAuth consent screen, you'll be prompted to do so. An email address and product name are required for the OAuth consent screen.

  1. Go to the OAuth consent screen.
    Configure consent screen
  2. Under Support email, select the email address you want to display as a public contact. This must be your email address, or a Google Group you own.
  3. Enter the Application name you want to display.
  4. Add any optional details you'd like.
  5. Click Save.

To change information on the OAuth consent screen later, such as the product name or email address, repeat the steps above to configure the consent screen.

Setting up Cloud IAP access

  1. Go to the Identity-Aware Proxy page.
    Go to the Identity-Aware Proxy page
  2. On the right side panel, next to Access, click Add.
  3. In the Add members dialog that appears, add the email addresses of groups or individuals to whom you want to grant the IAP-secured Web App User role for the project.

    Members can be:

    • Google Accounts: user@gmail.com
    • Google Groups: admins@googlegroups.com
    • Service accounts: server@example.gserviceaccount.com
    • G Suite domains: example.com

    Make sure to add a Google account that you have access to.

  4. When you're finished adding members, click Add.

Turning on Cloud IAP

  1. On the Identity-Aware Proxy page, under HTTPS Resources, find the App Engine app you want to restrict access to. The Published column shows the URL of the app. To turn on Cloud IAP for the app, click Off in the IAP column. toggle off
    • To enable Cloud IAP, you need the appengine.applications.update, clientauthconfig.clients.create, and clientauthconfig.clients.getWithSecret permissions. These permissions are granted by roles such as the Project Editor role. To learn more, see Managing access to Cloud IAP-secured resources.
  2. To confirm that you want the application to be secured by Cloud IAP, click Turn On in the Turn on IAP window that appears. After you turn it on, Cloud IAP requires login credentials for all connections to your application, and only accounts with the IAP-secured Web App User role on this project will be given access.

Test Access

  1. Access the app URL from the Google account that you added to Cloud IAP. You should have unrestricted access to the app.

  2. Next, use an incognito window in Chrome to access the app and sign in when prompted. If you try to access the app with an account that isn't authorized, you'll see a You don't have access message.

What's next

Var denne side nyttig? Giv os en anmeldelse af den:

Send feedback om...

Identity-Aware Proxy Documentation