0
我已創建shopify合作伙伴應用。應用程序與商店成功連接。之後,我在'訂單/更新'上創建了webhook。以下代碼位於webhook回調中,但Shopify API返回401 Unauzhorized。Shopify API返回401未經授權 - Ruby on Rails
url = request.headers['x-shopify-shop-domain'] # shop url
token = request.filtered_parameters["token"] # token from header
session = ShopifyAPI::Session.new(url, token) # create session
ShopifyAPI::Base.activate_session(session)
shop = ShopifyAPI::Shop.current # returns 401 Unauthorized
錯誤是以下幾點:
ActiveResource::UnauthorizedAccess (Failed. Response code = 401. Response message = Unauthorized.)
驗證使用SHARED_SECRET檢查webhook中數據的真實性。我無法在儀表板中找到SHARED_SECRET –
這只是您的祕密API密鑰 –
我已經嘗試將密鑰用作ShopifyAPI :: Session.new(url,sk) 的第二個參數,但我得到了同樣的錯誤。 –