GoogleOauth


Install

gem install googleoauth

or Gemfile:

gem 'googleoauth', '~> 0.0.3'


Usage (in Rails)

google_client = GoogleOAuth::Client.new(
    :client_id => 'CLIENT_ID',
    :client_secret => 'CLIENT_SECRET',
    :redirect => 'http://example.com:3000/callback',
)

if params[:code]
  google_client.authorize(:code => params[:code])
  response = google_client.request('/oauth2/v2/userinfo')
  puts response
else
  redirect_to google_client.authorize_url(:scope => 'profile email')
end