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) 的第二个参数,但我得到了同样的错误。 –