Skip to content

Instantly share code, notes, and snippets.

@sergiocampama
Created September 27, 2023 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sergiocampama/c8c07c6d526689b0897bb53c4107d338 to your computer and use it in GitHub Desktop.
Save sergiocampama/c8c07c6d526689b0897bb53c4107d338 to your computer and use it in GitHub Desktop.
@functions_framework.http
def main(request):
if "X-Hub-Signature-256" not in request.headers:
return "nok", 401
signature = hmac.new(
WHATSAPP_API_APP_SECRET.encode("utf-8"),
msg=request.get_data(as_text=True).encode("utf-8"),
digestmod=hashlib.sha256
).hexdigest()
if f"sha256={signature}" != request.headers["X-Hub-Signature-256"]:
return "nok", 401
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment