Skip to content

Catch MailGun WebHooks with Python3 + Flask + SQLAlchemy + Hashlib Signature Verification

Notifications You must be signed in to change notification settings

craigderington/flask-rest-mailgun-webhooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Catch MailGun WebHooks with Python3 + SQLAlchemy + Webhook Signature Verification

API Routes:

{
  "clicks": "/api/v1/wh/mg/lead/email/click", 
  "delivered": "/api/v1/wh/mg/lead/email/delivered", 
  "dropped": "/api/v1/wh/mg/lead/email/dropped", 
  "hard-bounce": "/api/v1/wh/mg/lead/email/bounced", 
  "opens": "/api/v1/wh/mg/lead/email/open", 
  "spam-complaint": "/api/v1.0/wh/mg/lead/email/spam/complaint", 
  "unsubscribe": "/api/v1.0/wh/mg/lead/email/unsubscribe"
}

Signature Verification:

def verify(api_key, token, timestamp, signature):
    hmac_digest = hmac.new(key=mailgun_api_key,
                           msg='{}{}'.format(timestamp, token).encode('utf-8'),
                           digestmod=hashlib.sha256).hexdigest()
    return hmac.compare_digest(signature, hmac_digest)

About

Catch MailGun WebHooks with Python3 + Flask + SQLAlchemy + Hashlib Signature Verification

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published