2017-02-27 95 views
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.) 

回答

0

看來你跳過了有關身份驗證的網絡掛接整體的一部分。爲確保您不會被垃圾毆打,您需要按照您的傳入數據執行此處列出的步驟:https://help.shopify.com/api/getting-started/webhooks#verify-webhook

+0

驗證使用SHARED_SECRET檢查webhook中數據的真實性。我無法在儀表板中找到SHARED_SECRET –

+0

這只是您的祕密API密鑰 –

+0

我已經嘗試將密鑰用作ShopifyAPI :: Session.new(url,sk) 的第二個參數,但我得到了同樣的錯誤。 –

相關問題