Skip to content

Instantly share code, notes, and snippets.

@matias-eduardo
Last active August 13, 2018 00:34
Show Gist options
  • Select an option

  • Save matias-eduardo/75b5efeef66a7d59e62a2bb42c5d8045 to your computer and use it in GitHub Desktop.

Select an option

Save matias-eduardo/75b5efeef66a7d59e62a2bb42c5d8045 to your computer and use it in GitHub Desktop.
Rails.application.config.middleware.use OmniAuth::Builder do
# Offline auth
provider :shopify,
ShopifyApp.configuration.api_key,
ShopifyApp.configuration.secret,
scope: ShopifyApp.configuration.scope,
setup: lambda { |env|
strategy = env['omniauth.strategy']
shopify_auth_params = strategy.session['shopify.omniauth_params']&.with_indifferent_access
shop = if shopify_auth_params.present?
"https://#{shopify_auth_params[:shop]}"
else
''
end
strategy.options[:client_options][:site] = shop
}
# Online auth
provider :shopify,
ShopifyApp.configuration.api_key,
ShopifyApp.configuration.secret,
scope: ShopifyApp.configuration.scope,
per_user_permissions: true,
setup: lambda { |env|
strategy = env['omniauth.strategy']
shopify_auth_params = strategy.session['shopify.omniauth_params']&.with_indifferent_access
shop = if shopify_auth_params.present?
"https://#{shopify_auth_params[:shop]}"
else
''
end
strategy.options[:client_options][:site] = shop
}
end
@matias-eduardo
Copy link
Author

I assume both sessions would clash here right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment