Skip to content

Instantly share code, notes, and snippets.

@mostlyfine
Last active June 14, 2016 06:06
Show Gist options
  • Save mostlyfine/22b25ee77a0d7b0384493efb20272629 to your computer and use it in GitHub Desktop.
Save mostlyfine/22b25ee77a0d7b0384493efb20272629 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'bundler'
Bundler.setup :default, :development, :example
require 'sinatra'
require 'omniauth'
require 'omniauth-google-oauth2'
use Rack::Session::Cookie
use OmniAuth::Builder do
provider :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET'], {
:scope => 'https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/plus.stream.read https://www.googleapis.com/auth/plus.stream.write https://www.googleapis.com/auth/plus.circles.read https://www.googleapis.com/auth/plus.circles.write'
}
end
get '/' do
<<-HTML
<ul>
<li><a href='/auth/google_oauth2'>Sign in with Google</a></li>
</ul>
HTML
end
get '/auth/:provider/callback' do
content_type 'text/plain'
request.env['omniauth.auth'].info.to_hash.inspect
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment