Sha256: 3e32980ab364dc7d68c68854367ffbaa48d29a6b4dab5c016d087b1cb4a3ac2b
Contents?: true
Size: 1.27 KB
Versions: 2
Compression:
Stored size: 1.27 KB
Contents
require 'omniauth/strategies/oauth2' module OmniAuth module Strategies class Shopify < OmniAuth::Strategies::OAuth2 # Available scopes: content themes products customers orders script_tags shipping # read_* or write_* DEFAULT_SCOPE = 'read_products' option :client_options, { :authorize_url => '/admin/oauth/authorize', :token_url => '/admin/oauth/access_token' } option :callback_url option :provider_ignores_state, true option :myshopify_domain, 'myshopify.com' uid { URI.parse(options[:client_options][:site]).host } def valid_site? !!(/\A(https|http)\:\/\/[a-zA-Z0-9][a-zA-Z0-9\-]*\.#{Regexp.quote(options[:myshopify_domain])}[\/]?\z/ =~ options[:client_options][:site]) end def fix_https options[:client_options][:site].gsub!(/\Ahttp\:/, 'https:') end def setup_phase super fix_https end def request_phase if valid_site? super else fail!(:invalid_site) end end def authorize_params super.tap do |params| params[:scope] ||= DEFAULT_SCOPE end end def callback_url options[:callback_url] || super end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
omniauth-shopify-oauth2-1.1.7 | lib/omniauth/strategies/shopify.rb |
omniauth-shopify-oauth2-1.1.6 | lib/omniauth/strategies/shopify.rb |