require 'bundler/setup' require 'sinatra/base' require 'omniauth-duodealer-oauth2' SCOPE = 'read_products,read_orders,read_customers,write_shipping' DUODEALER_API_KEY = ENV['DUODEALER_API_KEY'] DUODEALER_SHARED_SECRET = ENV['DUODEALER_SHARED_SECRET'] unless DUODEALER_API_KEY && DUODEALER_SHARED_SECRET abort("DUODEALER_API_KEY and DUODEALER_SHARED_SECRET environment variables must be set") end class App < Sinatra::Base get '/' do <<-HTML
Shop: #{request.env['omniauth.auth'].uid}
Token: #{request.env['omniauth.auth']['credentials']['token']}
HTML end get '/auth/failure' do <<-HTMLMessage: #{params[:message]}
HTML end end use Rack::Session::Cookie, secret: SecureRandom.hex(64) use OmniAuth::Builder do provider :duodealer, DUODEALER_API_KEY, DUODEALER_SHARED_SECRET, :scope => SCOPE end run App.new