Skip to content

Instantly share code, notes, and snippets.

@andrewfraley
andrewfraley / verify_github_webhook_signature.py
Created March 12, 2019 21:19
Validate Github webhook signature/secret in python3
def validate_signature(payload, secret):
# Get the signature from the payload
signature_header = payload['headers']['X-Hub-Signature']
sha_name, github_signature = signature_header.split('=')
if sha_name != 'sha1':
print('ERROR: X-Hub-Signature in payload headers was not sha1=****')
return False
# Create our own signature