Java 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. Otherwise, read on to see how to deploy your own version.

Download on GitHub

Prerequisites

Ensure your system meets the following prerequisites for the quick start project:

  • Java 1.6
  • Apache Maven - used for part of the build process.

Creating a Google APIs Console project

Next, enable access to the Google Mirror API:

  1. Go to the Google 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
  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
  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
  5. Select Web application and specify any value for the hostname, such as localhost selecting application type
  6. Click Edit settings... for the client ID to specify redirect URIs. Specify the callback URLs for your local development web server, for example http://localhost:8080/oauth2callback, and for your deployed web server, for example https://example.com/oauth2callback. the Google API console configuration panel for redirect URIs
  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

Configuring the Quick Start project

Configure the Quick Start project to use your API client information by entering your client ID and secret into src/main/resources/oauth.properties:

    # Replace these with values for your project from the Google API Console:
    # https://developers.google.com/console

    client_id=3141592653589793238462643383279
    client_secret=ITS_A_SECRET_TO_EVERYBODY

Importing the project

The following instructions show you to import the Quick Start project source into IntelliJ and Eclipse.

IntelliJ

  1. Click File > Import Project....
  2. Point to the extracted directory.
  3. Select Import from existing model > Maven

Eclipse

  1. Install the m2e plugin to enable import from a maven pom file.
  2. Click File > Import... > Maven > Existing Maven Project.
  3. Point to the extracted directory and import the project.

Running a local development server

You can run the Quick Start project on a local development server for testing:

$ mvn jetty:run

Deploying the Quick Start project

You can build a war file for this project using Maven:

$ mvn war:war