Shopify app登录问题

San*_*osh 4 ruby-on-rails shopify

我已经在Shopify应用程序上从遗留系统切换到oauth2身份验证.现在,每当我从商店管理页面(我的应用程序 - >应用程序)访问应用程序时,它都会将我重定向到登录页面,而不是直接将商店记录到应用程序中(就像之前一样).

下面是finalize方法中的代码.

if response = request.env['omniauth.auth']
  sess = ShopifyAPI::Session.new(params['shop'], response['credentials']['token'])
  ShopifyAPI::Base.activate_session(sess)
  session[:shopify] = sess
  flash[:notice] = "Logged in"
  redirect_to return_address
  session[:return_to] = nil
else
  flash[:error] = "Could not log in to Shopify store."
  redirect_to :action => 'index'
end
Run Code Online (Sandbox Code Playgroud)

当用户从商店管理页面访问应用程序时,它在请求中没有request.env ['omniauth.auth']并被重定向到登录页面,因为当我们有遗留身份验证机制时不是这种情况.

应用网址是www.orderlyprint-staging.herokuapp.com.您可以在测试商店中安装该应用程序,并尝试从测试商店的管理页面登录该应用程序.

Bjo*_*erg 6

对于最初使用Shopify App gem构建的Shopify应用程序,以及从Legacy切换到oAuth2身份验证解决方案时,您需要将Shopify Admin链接指向authenticate操作而不是finalize操作.所以你需要:

转到Shopify合作伙伴管理员

按Edit App Details

更新"应用程序URL"以指向验证操作.例如:www.orderlyprint-staging.herokuapp.com/login/authenticate

然后,这将提取Shopify发送的商店参数,并执行oAuth身份验证的初始步骤,然后重定向到完成操作以完成.然后,这将自动登录用户,而无需他们手动输入他们的商店URL.