Skip to content

Instantly share code, notes, and snippets.

@yowchun93
Created April 23, 2020 01:50
Show Gist options
  • Save yowchun93/b0b5cbf7afecaaf337d8c8125b4afe94 to your computer and use it in GitHub Desktop.
Save yowchun93/b0b5cbf7afecaaf337d8c8125b4afe94 to your computer and use it in GitHub Desktop.
ShopifySession
gem 'shopify_app'
ShopifyApp
def callback
if auth_hash
end
end
def login_shop
reset_session_options
set_ecommerce_api_session
end
def reset_session_options
request.session_options[:renew] = true
session.delete(:_csrf_token)
end
def set_ecommerce_api_session
session_store =
ShopifyAPI::Session.new(
domain: shop_name,
token: token,
api_version: ShopifyApp.configuration.api_version
)
ShopifyAPI::Base.activate_session(session_store)
session[:shopify] = ShopifyApp::SessionRepository.store(session_store)
session[:shopify_domain] = shop_name
session[:shop_domain] = shop_name
session[:shopify_user] = associated_user
end
// few key methods in used.
ShopifyApp::SessionRepository.store(session_store)
ShopifyApp.configuration
// session, request.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment