# Python Quick Start

This project shows you how to implement a simple
piece of Glassware that demos the major functionality of the Google Mirror API.

To see a fully-working demo of the quick start project, go to
[https://glass-python-starter-demo.appspot.com](https://glass-java-starter-demo.appspot.com).
Otherwise, read on to see how to deploy your own version.

[Download on GitHub](https://github.com/googleglass/mirror-quickstart-python)

## Prerequisites

[The App Engine SDK for Python](https://developers.google.com/appengine/downloads#Google_App_Engine_SDK_for_Python) -
The Python quick start project is implemented using App Engine. You need
the Python App Engine SDK to develop and deploy your project.
Run the installer if appropriate for your platform, or extract the zip file
in a convenient place.

## Creating a Google App Engine instance

You'll need to host the quick start project on an instance of Google App Engine:

1. Go to <http://appspot.com>.
2. Click **Create Application** and create a public Google App Engine instance hosted on `appspot.com`.
3. Give the application an **Application Identifier** and leave the authentication **Open to all Google
   Accounts users**. You'll need the application identifier later to configure the quick start project.

## Creating a Google APIs Console project

Next, enable access to the Google Mirror API:

1. Go to the [Google APIs console](https://code.google.com/apis/console/) and create a new API project.
2. Click **Services** and enable the Google Mirror API for your new project. ![the Google Mirror API on the Google API Console](https://developers.google.com/static/glass/images/api-console-enable-glass.png)
3. Click **API Access** and create an OAuth 2.0 client ID for a web application. ![the API Access section of the Google API console](https://developers.google.com/static/glass/images/api-console-client-id.png)
4. Specify the product name and icon for your Glassware. These fields appear on the OAuth grant screen presented to your users. ![specifying brand information](https://developers.google.com/static/glass/images/api-console-client-id-brand-info.png)
5. Select **Web application** and specify any value for the hostname, such as `localhost` ![selecting application type](https://developers.google.com/static/glass/images/api-console-client-id-app-type.png)
6. Click **Edit settings...** for the client ID to specify redirect URIs. Specify `http://localhost:8080/oauth2callback` and the callback URL for your App Engine instance, for example, `https://myappengineinstance.appspot.com/oauth2callback`. ![the Google API console configuration panel for redirect URIs](https://developers.google.com/static/glass/images/api-console-redirect-uris.png)
7. Make note of the client ID and secret from the Google APIs Console. You'll need it to configure the quick start project. ![the client id and secret on the Google API console](https://developers.google.com/static/glass/images/api-console-client-id-and-secret.png)

## Configuring the project

Configure the Quick Start project to use your API client information:

1. Enter your client ID and secret in `client_secrets.json`:

   ```python
   {
     "web": {
       "client_id": "1234.apps.googleusercontent.com",
       "client_secret": "ITS_A_SECRET_TO_EVERYBODY",
       "redirect_uris": [
       ],
       "auth_uri": "https://accounts.google.com/o/oauth2/auth",
       "token_uri": "https://accounts.google.com/o/oauth2/token"
     }
   }
   ```
2. Generate a `session.secret` file to store session cookies:

   ```python
   $ python -c "import os; print os.urandom(64)" > session.secret
   ```
3. Edit `app.yaml` to enter your App Engine application ID:

   ```python
   application: your_app_engine_application_id
   version: 1
   runtime: python27
   api_version: 1
   threadsafe: true
   ...
   ```

## Deploying the project

Press the blue **Deploy** button in the App Engine Launch GUI interface or run this shell
command to deploy your code:

    $ appcfg.py --oauth2 update .