require 'rubygems' require 'sinatra' require 'json' require 'omniauth' require 'omniauth-mvc' class SinatraApp < Sinatra::Base configure do set :sessions, true set :inline_templates, true end use OmniAuth::Builder do provider :mvc, ENV['APP_ID'], ENV['APP_SECRET'], display: 'popup', callback_url: ENV['CALLBACK_URL'] end get '/' do erb " Login with MVC" end get '/auth/:provider/callback' do erb "
#{JSON.pretty_generate(request.env['omniauth.auth'])}" end get '/auth/failure' do erb "
#{params}" end get '/auth/:provider/deauthorized' do erb "#{params[:provider]} has deauthorized this app." end get '/protected' do throw(:halt, [401, "Not authorized\n"]) unless session[:authenticated] erb "
#{request.env['omniauth.auth'].to_json}