Created
September 27, 2023 18:27
-
-
Save sergiocampama/c8c07c6d526689b0897bb53c4107d338 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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