Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Google Mirror API's Quickstart for Ruby (deprecated)
Ruby CSS
Branch: master

Merge pull request #3 from googleglass/deprecate

Deprecating the Ruby Quick Start
latest commit 8ea10c6657
@allevato allevato authored
Failed to load latest commit information.
public
views
.gitignore
CONTRIBUTING.md
Gemfile
Gemfile.lock
LICENSE
README.md
client_secrets.json
credentials_store.rb
mirror_client.rb
mirror_quick_start.rb
oauth_utils.rb

README.md

Deprecation Notice

This sample project has been deprecated. It is no longer being actively maintained and is probably out of date.

In other words, if you decide to clone this repository, you're on your own.

Google Mirror API's Quick Start for Ruby (using Sinatra)

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

Prerequisites

  • Ruby 1.9 or higher
  • To use subscriptions, you also need an Internet accessible hosting environment with a valid SSL certificate signed by a trusted certificate authority.

Note: You can start developing with a localhost instance of your HTTP server, but you must have an Internet accessible host to use the subscription features of the API.

Configuring the project

Enter your client ID, secret, and an OAuth2 redirect URL in client_secrets.json:

{
    "web": {
        "client_id": "1234.apps.googleusercontent.com",
        "client_secret": "ITS_A_SECRET_TO_EVERYBODY",
        "redirect_uris": [
            "http://example.com/oauth2callback"
        ],
        "auth_uri": "https://accounts.google.com/o/oauth2/auth",
        "token_uri": "https://accounts.google.com/o/oauth2/token"
    }
}

Installing gem dependencies

This example uses Bundler to manage gem dependencies. Before running the script for the first time, run the following command from a terminal in the directory containing the Quick Start files to install the required gems:

$ bundle install

Running a local development server

Before deploying to your production server, you can run the Quick Start project as a local development server for testing. This application is written using the Sinatra micro-framework, and you can launch it as a standard Ruby script from the terminal:

  1. From a terminal in the directory containing your Quick Start files, run:

    $ ruby mirror_quick_start.rb
    
  2. Start using the Quick Start on your default browser at http://localhost:4567.

Deploying the project

To deploy the Quick Start to your host server, copy the Ruby Quick Start directory to your web server and configure it as a Rack application per your server's instructions. Phusion Passenger along with Apache httpd or nginx work great. For detailed instructions on deploying a Sinatra application to either of these servers, please refer to the Phusion Passenger users guide for Apache or nginx.

Something went wrong with that request. Please try again.