google-oauth

Thin ruby wrapper for the various Google OAuth 2 APIs

Notice

I created this for use in a school project. It’s still very raw and not ready for general public consumptions yet.

Install

gem install google-oauth

Examples

# set up the connection
require 'google_oauth'
GoogleOAuth.configure do |s|
  s.client_id = CLIENT_ID
  s.client_secret = CLIENT_SECRET
  s.scope = 'userinfo.email,userinfo.profile,http://www.google.com/calendar/feeds/,http://www.google.com/m8/feeds/'
  s.host = "http://localhost:3000"
end
user = User.first
oauth = u.authentications.first
# you can manually pass in the tokens here but passing in
# the oauth activerecord object is a convenient shortcut
# This also supports updating of your refresh token
client = GoogleOAuth::Client.new(:authentication => oauth)

# Getting a list of calendars
client.calendar_list

# Getting data from your primary calendar
client.get_calendar

Future work

I hope to rewrite most of this so that there’s a much nicer DSL for general consumption with tests and better documentation.

Contributing to google-oauth

Copyright © 2012 Kang Chen. See LICENSE.txt for further details.