Shopify :: Activeresource :: ForbidenaCcess:失败.响应代码=403.响应消息



我已经发送了该应用程序(尚未列出)以进行审查。审阅者正在收到有关Homecontroller的索引操作的上述错误,该错误在用户单击安装按钮时会触发。我在不同合作伙伴帐户中使用许多开发商店验证了该应用程序。我能够为我测试过的所有商店成功安装该应用程序。

这是代码的简化版本

控制器/shopify/home_controller.rb

module Shopify
  class HomeController < ShopifyApp::AuthenticatedController
    def index
      MyCustomServie.new(shopify_detail).call
    end
    private
    def current_shopify_store
      @current_shop ||= begin
        Shopify::Base.with_rate_limit_protection do
          ShopifyAPI::Shop.current
        end
      end
    end
    def shopify_detail
      @shopify_detail ||= ShopifyDetail.find_by(shopify_domain: current_shopify_store.try(:myshopify_domain))
    end
  end
end

config/initializers/omniauth.rb

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :shopify,
    ShopifyApp.configuration.api_key,
    ShopifyApp.configuration.secret,
    scope: ShopifyApp.configuration.scope,
    callback_path: "#{Settings.shopify.mounted_at}/auth/shopify/callback"
  provider :google_oauth2,
           Settings.google.client_id,
           Settings.google.client_secret,
          { access_type: "offline", approval_prompt: "" }
end

conffig/initializers/shopify_app.rb

ShopifyApp.configure do |config|
  config.application_name = 'Shopify - Feed Champion'
  config.api_key = Settings.shopify.api_key
  config.secret = Settings.shopify.api_secret
  config.scope = Settings.shopify.scope
  config.embedded_app = true
  config.after_authenticate_job = { job: ShopifyAfterAuthenticateJob, inline: true }
  config.webhooks = [  Shopify::AppUninstalledWebhook::PARAMS  ]
end

错误来自以下行 ShopifyAPI::Shop.current

这是错误日志。有人可以给指针在哪里可能是问题吗?

作为Shopify的新手,我错过了使用可用的Shopify API所需的范围,并且遇到了相同的ForbiddenAccess错误。在shopify_app.rb中,我添加了缺少的范围。获取Shopify商店的所有产品和客户的示例:

config.scope =" read_products,read_customers"

这是所有可用范围的列表。

最新更新