401 on subsequent API calls after successful call.

Shopify Partner
1 0 0

We are a 3rd party app that integrates with shopify via the ShopifyApi Ruby gem. We have customers sync their products and orders. We do this serially: products first, then orders.


We authorize using OAuth. We are having what we think are rare scenarios where a customer will successfully sync their products, but then orders will fail. When I check the logs I find 401 Unauthorized errors. If I dip into a ruby console and run the following code it fails. 



session = ShopifyAPI::Session.new(store, access_token)
# or



This seems odd, because I can see records of the products on our server so I know we successfully were able to call out to the API with a valid token moments before to get the products. This process is a fast process too so it seems unlikely that tokens expired.


The products and orders are synced via separate micro services. Could the fact that the calls are coming from different IPs matter? I'm really scratching my head on this one. I can provide more information if it's needed. Thanks for any help!

Reply 1 (1)
Shopify Staff
Shopify Staff
1561 81 339

Calls from different IPs should not matter, all that matters is the access token used. Do you use online access tokens, offline access tokens, or both? Are you checking the value of `access_token` at the time your are able to replicate the issue? If you take that access token and try to make a curl request with it, does that work?


After considering the above, you could give me a request ID (response header) and I can use that to check my logs as long as it occurred in the past 12 days.

Alex | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog