A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hello ,
I wrote a simple script to find out shops having a webhook registered. But it gives 401 Unauthorized error for a lot of shops even though the app is installed and functioning on those shops. It does give correct count for some of the shops. Here is the code
Shop.all.each do |shop|
puts shop.shopify_domain
begin
shop.with_shopify_session do
pp "count: " +(ShopifyAPI::Webhook.all.nil? ? "0": ShopifyAPI::Webhook.all.count.to_s)
end
rescue ActiveResource::UnauthorizedAccess => e
puts e.message
end
end
What could be the reason for it and how can I debug it?
Have you verified access scopes allowed for each shop you are hitting? If some return results while others don't perhaps that's the issue? See here --> https://shopify.dev/docs/admin-api/rest/reference/access/accessscope
Thanks for replying. But I still got the same 401 Unauthorized access for the shops.
I'd suggest posting one of the failed X-Request-ID's, which are passed back in the response header. A Shopify support staffer can cross-reference the request ID to see what's going on.
@Gregarican
Here is the X-Request-ID: b2a9ce97-93ae-4a0e-80c9-e8eb3991172d and X-ShopID : 1609924677
Hi,
Is this script executed when the shop owners are offline (logged out)? If you use online access mode the access token expire with the user's sessions and then you get the Unauthorized Error. Can you show me the exact error message?