【发布时间】:2021-01-08 12:00:12
【问题描述】:
我开始使用 Shopify 应用开发。我正在开发一个嵌入式 Shopify 应用程序,它将安装到 Shopfify 商店。安装后,我希望为 Shopify 商店管理员和 Shopify 嵌入式应用程序的管理员提供单独的网页,他们可以在其中查看统计信息并执行一些操作。 (我不知道我是否应该将这些页面保留在 shopify 商店域或外部托管域中,关于哪个适合此用例的任何建议?)
我正在使用shopify_app 和shopify_api gems 在Ruby on Rails 中构建它。
我面临的问题是,在将应用程序安装到 Shopify 商店后,默认情况下它会被重定向到 /auth/shopify/callback,由 shopify_app 引擎处理并重定向应用程序安装程序(shopify 商店所有者/商家) shopify 商店的域名(见此代码here)。
module ShopifyApp
# Performs login after OAuth completes
class CallbackController < ActionController::Base
include ShopifyApp::LoginProtection
def callback
return respond_with_error if invalid_request?
store_access_token_and_build_session
if start_user_token_flow?
return respond_with_user_token_flow
end
perform_post_authenticate_jobs
respond_successfully
end
private
def respond_successfully
if jwt_request?
head(:ok)
else
redirect_to(return_address)
end
end
end
end
return_address 的定义是
def return_address
return base_return_address unless ShopifyApp.configuration.allow_jwt_authentication
return_address_with_params(shop: current_shopify_domain)
rescue ShopifyDomainNotFound
base_return_address
end
我想要做的是在安装应用程序后(授予 oauth 权限)我想重定向到自定义 URL(最好是一些外部网站,我将为 Shopify 商店管理员和 Shopiy 应用程序管理员托管) , 这怎么可能?
基本上我正在尝试的是转到自定义 URL 而不是
return_address_with_params(shop: current_shopify_domain)一旦我们被重定向到该外部 URL,关于如何处理身份验证的任何指示?
我刚开始使用 Shopify 应用程序开发,这就是我无法理解这些流程的原因。任何帮助表示赞赏。
谢谢
【问题讨论】:
标签: ruby-on-rails ruby shopify shopify-app