Sha256: 2cda52cb33d5965805a14ce7e06884bcf2c0ed99c4b9a0e36800cc6aa7cdc002
Contents?: true
Size: 1.05 KB
Versions: 8
Compression:
Stored size: 1.05 KB
Contents
require 'bundler/setup' require 'sinatra/base' require 'omniauth-shopify-oauth2' SCOPE = 'read_products,read_orders,read_customers,write_shipping' class App < Sinatra::Base get '/auth/:provider/callback' do <<-HTML <html> <head> <title>Shopify Oauth2</title> </head> <body> <h3>Authorized</h3> <p>Token: #{request.env['omniauth.auth']['credentials']['token']}</p> </body> </html> HTML end get '/auth/failure' do <<-HTML <html> <head> <title>Shopify Oauth2</title> </head> <body> <h3>Failed Authorization</h3> <p>Message: #{params[:message]}</p> </body> </html> HTML end end use Rack::Session::Cookie use OmniAuth::Builder do provider :shopify, ENV['SHOPIFY_API_KEY'], ENV['SHOPIFY_SHARED_SECRET'], :scope => SCOPE, :setup => lambda { |env| params = Rack::Utils.parse_query(env['QUERY_STRING']) env['omniauth.strategy'].options[:client_options][:site] = "https://#{params['shop']}" } end run App.new
Version data entries
8 entries across 8 versions & 1 rubygems