When shopify sends a webhook to my app, I want to access the products resource of the shop owner's store through the API and compare the ids of the product in the store and the product ordered by the customer.
app/views.py
@csrf_exempt
def webhook (request, *args, **kwargs):
products = []
import shopify
with request.user.session: # This doesn't work because no login I think
products = shopify.Product.find()
print "THE PRODUCTS ARE:", products
if request.method == "POST":
line_items = json.loads(request.body)["line_items"]
return HttpResponse(status=200)
I can't do this because the user isn't logged in so the request.user.session doesn't work.
I can't ask the webhook to login to the owner's store for me.
So, how do I access the products like shopify.Product.find() in this function?