Verifying Shopify Proxy Requests in Python
I’ve been playing around with Shopify’s application proxy feature of late as part of my work for Disco’s upcoming range of applications.
Translating the Ruby code examples in the docs to Python is usually pretty straightforward, but it’s even more straightforward to just copy and paste from the internet – so with that in mind, thought I’d share this snippet to verify a signed application proxy request.
You’d use it something like this:
from snippet import proxy_signature_is_valid def my_view(request, *args, **kwargs): if not proxy_signature_is_valid(request, settings.SHOPIFY_APP_SECRET): raise Exception('Invalid signature.') ... (regular view code here) ...
Short and sweet. If you want to see the original Ruby implementation provided by the official docs, that’s here.