Creating an HMAC and pushing data to a JSON Webhook connector with a secret applied

It can be a little confusing when trying to setup the JSON Webhook connector with a secret applied and push data successfully.
The biggest hurdle can often be creating the HMAC to pass in through the header. Depending on the source that you're pushing from or what programming language you're using will change the setup process and/or the libraries used. But the format of the HMAC is the same. The secret will be used as the key in the HMAC, your JSON body (data) will be the included message, and then either SHA1, SHA256 or SHA512 for the hash algorithm.
I've created an example written in Python of the process of creating an HMAC and pushing the data into Domo through the JSON Webhook connector with the secret "webhookSecret" applied to the connector.
import requests import hashlib import hmac def jsonWebhookSecretExample(): url = 'https://example.domo.com/api/iot/v1/webhook/data/aseKEdjweksKSSPwasjdflKEecklsClsjeQ' jsonStr = '{"data": [{"name": "Ashley", "age": 22}, {"name": "Ben", "age": 24}, {"name": "Melissa", "age": 31}, {"name": "Eddy", "age": 29}]}' key = 'webhookSecret' byteKey = bytes(key, 'UTF-8') message = jsonStr.encode() hashed = hmac.new(byteKey, message, hashlib.sha1) response = requests.post(url, headers={'X-Hub-Signature': hashed.hexdigest(), 'Content-Type': 'application/json'})
Comments
-
Thanks so much for this post. Been trying to work this out. I notice there is not "data="/payload in the post request. Is this right? I am getting a http 200 back but data doesn't seem to be adding to the dataset.
0 -
For me to get this to work I had to add the "data=" parameter in the request:
response = requests.post(url, headers={'X-Hub-Signature': hashed.hexdigest(), 'Content-Type': 'application/json'}, data=jsonStr)
0 -
Setting up the JSON Webhook connector with a secret can be tricky, especially when generating the HMAC correctly. If you're working on IoT integrations, this guide might be useful: https://blog.urlaunched.com/wearable-iot-development-for-healthcare-startups/
0
Categories
- All Categories
- 1.9K Product Ideas
- 1.9K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 306 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 3K Transform
- 112 SQL DataFlows
- 649 Datasets
- 2.2K Magic ETL
- 4K Visualize
- 2.5K Charting
- 787 Beast Mode
- 78 App Studio
- 43 Variables
- 742 Automate
- 187 Apps
- 474 APIs & Domo Developer
- 67 Workflows
- 14 DomoAI
- 40 Predict
- 17 Jupyter Workspaces
- 23 R & Python Tiles
- 406 Distribute
- 117 Domo Everywhere
- 279 Scheduled Reports
- 10 Software Integrations
- 139 Manage
- 136 Governance & Security
- 8 Domo Community Gallery
- 44 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 113 Community Announcements
- 4.8K Archive