google-api-ruby-client/samples/web
Daniel Azuma d30bfb4084
docs: Update readme and samples to reflect separated packages
2021-01-07 13:31:56 -08:00
..
views #402 - Remove errant line 2016-04-25 10:51:01 -07:00
Gemfile docs: Update readme and samples to reflect separated packages 2021-01-07 13:31:56 -08:00
README.md Add a small web sample showing incremental authorization & use of APIs 2016-01-20 12:21:08 -08:00
app.rb Add a small web sample showing incremental authorization & use of APIs 2016-01-20 12:21:08 -08:00

README.md

API Samples

This directory contains a simple Sinatra web app illustrating how to use the client in a server-side web environment.

It illustrates a few key concepts:

Setup

  • Create a project at https://console.developers.google.com
  • Go to the API Manager and enable the Drive and Calendar APIs
  • Go to Credentials and create a new OAuth Client ID of type 'Web application'
    • Use http://localhost:4567/oauth2callback as the redirect URL
    • Use http://localhost:4567 as the JavaScript origin

Additional details on how to enable APIs and create credentials can be found in the help guide in the console.

Example Environment Settings

For convenience, application credentials can be read from the shell environment or placed in a .env file.

After setup, your .env file might look something like:

GOOGLE_CLIENT_ID=479164972499-i7j6av7bp2s4on5ltb7pjXXXXXXXXXX.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=JBotCTG5biFWGzXXXXXXXXXX

Running the samples

To start the server, run

ruby app.rb

Open http://localhost:4567/ in your browser to explore the sample.