Getting Started with the Admin API

This guide is designed to help you learn how to use the Google App Engine Admin API to deploy
a sample Python application to App Engine. You can use the overall process to
gain insight into how you can create code that programmatically manages and
deploys your apps.

In this guide, the sample used is a simple Hello World app that
displays the text "Hello, World!" and is available in
GitHub.
For authorization with the Cloud Platform Console, an OAuth client ID and a
web browser is used. To demonstrate the individual steps of the process, cURL
commands are provided so that you can send HTTP requests from your terminal.

Tip: To play around and see what the API can do
without writing any code or setting up projects and credentials, visit the
APIs Explorer.

Optional: Configure traffic to the version where you deployed the sample app.

Note: Typically, you must first create a Google Cloud Storage bucket and
then upload a copy of your app before you can deploy it to App Engine with
the Admin API. However, this guide uses Hello World app resources
that have already been uploaded to a public Cloud Storage bucket. For more
information about the deployment process, see
Deploying Versions of Your App.

Before you begin

Download and install the Google Cloud SDK and then initialize the
gcloud tool:Download the SDK

Important: The steps and all the corresponding examples refer to the example
Cloud Platform project [MY_PROJECT_ID]. To run the commands against
your project, you must replace all instances of [MY_PROJECT_ID] with your
project ID. For information about creating a Cloud Platform project, see the
instructions for your language:
standard environment or
flexible
environment.

Configuring your Cloud Platform project

In the wizard, select an existing project from the list or click
Continue to create a new project.

Click Continue to create an OAuth client ID credential:

In the OAuth consent screen specify at least your
Email address and the Product name shown to users.

Save the consent screen settings and then switch to the
Credentials tab by clicking Save.

Click Create credentials and then OAuth client ID to create a
client ID.

Click Web application, specify a name, and then use
https://www.google.com as the redirect URI.

Note: The redirect URI defines where the HTTP response is sent. The
https://www.google.com URI is used in this guide as an example but
for production, you must specify your application's auth endpoint,
which handles responses from the OAuth 2.0 server.

Click Create to save the credential.

Take note of the client ID that is displayed because it will be used
in a later step for requesting your access token.

For more information about creating credentials for the Admin API,
see Accessing the API.

Creating a configuration file

Create a configuration file that defines the Hello World app deployment. In a
file named app.json, you define the Google Cloud Storage bucket of the Hello World
app in the sourceURL field and the configuration information for the version,
including the version ID in the id field.

For example, root/python-docs-samples/appengine/standard/hello_world/app.json

Note: Typically you use the convert_yaml.py
tool
to create a JSON formatted configuration file. You convert the
app.yaml file of your app and then
define all of the app's resources that you want to deploy from your
Cloud Storage bucket. For more information about converting app.yaml
files, see Deploying Versions To Your
Application.

Authorizing HTTP requests

Authenticate with App Engine so that you can send HTTP requests with the
Admin API.

Use either of the following options to help you quickly get started. Both
the HTTPS and gcloud options provide you with manual, yet simple, steps for
obtaining access tokens for the purposes of trying out the Admin API.

HTTPS

To simulate a client-side OAuth 2.0 flow, add your OAuth client ID
credential to a URI, and then send the HTTPS request through your web
browser:

In your web browser, request an access token by using the client ID of
your API credentials. The following example uses client_id=[MY_CLIENT_ID]
and redirect_uri=https://www.google.com, where [MY_CLIENT_ID] is the
client ID of the
credential
that you created earlier: