Skip to content

Instantly share code, notes, and snippets.

@thewheat
Last active April 9, 2019 08:13
Show Gist options
  • Save thewheat/98024f005d618ae16249 to your computer and use it in GitHub Desktop.
Save thewheat/98024f005d618ae16249 to your computer and use it in GitHub Desktop.
Process Intercom's Webhook with Django
# Don't forget to modify urls.py accordingly to allow routing to the function
# url(r'', views.index)
from django.views.decorators.csrf import csrf_exempt
import hashlib
import hmac
from django.http import HttpResponse
@csrf_exempt
def index(request):
KEY = "YOUR_HUB_SECRET"
if request.method == "POST" :
SIGNATURE = request.META.get('HTTP_X_HUB_SIGNATURE')
MESSAGE = request.body
calculated = hmac.new(KEY, MESSAGE, hashlib.sha1).hexdigest()
calculated = "sha1=" + (calculated)
print "Found : " + SIGNATURE
print "Generated : " + calculated
if calculated == SIGNATURE:
print " YES! "
else:
print " No..... =( "
return HttpResponse()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment