Sha256: b9e6f575ddc5f9f61196cb4213f4ee866f350dcb21d4603be881b20d8119f46b
Contents?: true
Size: 1.19 KB
Versions: 15
Compression:
Stored size: 1.19 KB
Contents
# Sample app for Google OAuth2 Strategy # Make sure to setup the ENV variables GOOGLE_KEY and GOOGLE_SECRET # Run with "bundle exec rackup" require 'rubygems' require 'bundler' require 'sinatra' require 'omniauth' require 'omniauth-google-oauth2' # Do not use for production code. # This is only to make setup easier when running through the sample. # # If you do have issues with certs in production code, this could help: # http://railsapps.github.io/openssl-certificate-verify-failed.html OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE class App < Sinatra::Base 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'].to_hash.inspect rescue "No Data" end get '/auth/failure' do content_type 'text/plain' request.env['omniauth.auth'].to_hash.inspect rescue "No Data" end end use Rack::Session::Cookie, :secret => ENV['RACK_COOKIE_SECRET'] use OmniAuth::Builder do # For additional provider examples please look at 'omni_auth.rb' provider :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET'], {} end run App.new
Version data entries
15 entries across 15 versions & 1 rubygems