logo
down
shadow

Using a Zapier Custom Request Webhook with JSON Web Tokens


Using a Zapier Custom Request Webhook with JSON Web Tokens

By : B.Gelinas
Date : November 21 2020, 07:01 PM
will be helpful for those in need My experience authenticating with APIs has been using the simple API key method. As such I first read your question and didn't fully understand. I decided to do some research and hopefully learn something along the way, and I certainly did. I share my findings and answer below:
For starters I began reading into JSON Web Tokens(JWT) which lead me to the JWT website, which was an excellent resource. It very clearly spells out the components that make up a JWT and how they need to be formatted, I would highly recommend having a look.
code :
import hashlib
import hmac
import requests
from base64 import urlsafe_b64encode

def base64url_encode(payload):
  if not isinstance(payload, bytes):
    payload = payload.encode('utf-8')
  encode = urlsafe_b64encode(payload)
  return encode.decode('utf-8').rstrip('=')

def generate_JWT(header, payload, secret):

  encoded_header = base64url_encode(header)
  encoded_payload = base64url_encode(payload)

  signature = hmac.new(secret,
                      encoded_header + "." + encoded_payload, 
                      hashlib.sha256)
  encoded_signature = base64url_encode(signature.digest())

  return encoded_header + "." + encoded_payload + "." + encoded_signature

def get_request(url, jwt):

  headers = {
    "Authorization" : "Bearer " + jwt
  }

  result = requests.get(url, headers=headers)
  return result

secret = "yoursecrettoken"
header = '{"alg":"HS256","typ":"JWT"}'
payload = '{"sub":"1234567890","name":"John Doe","iat":1516239022}'
jwt = generate_JWT(header, payload, secret)

response = get_request("https://SomeApiEndpoint.com/api/", jwt)


Share : facebook icon twitter icon
Accessing request headers with Zapier Webhook triggers

Accessing request headers with Zapier Webhook triggers


By : Hakan Kurhan
Date : March 29 2020, 07:55 AM
I wish did fix the issue. David here, from the Zapier Platform team.
Sorry to be the bearer of bad news, but this isn't something we currently support in our webhooks app. If the proxy server isn't an option, it might be possible to write a custom CLI app to catch your hooks. It has access to the incoming header and could copy that information into the body. The tricky part of that is that you no longer have the benefit of a single URL to throw hooks at - each zaps broadcasts its url when it's turned on. Success would depend on being able to capture that broadcast somewhere and adjust your data accordingly.
How can I read a json webhook from mixpanel using Zapier?

How can I read a json webhook from mixpanel using Zapier?


By : user1385138
Date : March 29 2020, 07:55 AM
should help you out You don't need any code to make it work.
Type 'users' in 'Pick off a Child Key'. (Trigger > Edit Options)
Get PHP response into Zapier webhook

Get PHP response into Zapier webhook


By : user2439059
Date : March 29 2020, 07:55 AM
With these it helps I finally found it out by myself. I have to return one JSON, which includes everything. It's also not possible to echo anything at the same time as this would result in the output of just one string with all the values in it (like I had it before).
So something like this does the job:
code :
if (!isset($returnValue)) {
  $returnValue = new stdClass();
  $returnValue->order_id = $orderID;
  $returnValue->result_message = $resultMessage;
}

print_r(json_encode($returnValue));
$.post to Zapier webhook

$.post to Zapier webhook


By : user2451657
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , I have created an HTML form that sends an HTTP POST to a Zapier webhook. The code works great when I embed the POST action in HTML:
code :
var data = {
            message : 'test stack overflow',
            contact : 'test'
        };
$.ajax({
        type : 'POST',
        url : 'https://hooks.zapier.com/hooks/catch/2689457/xiooqx/',  
        data: JSON.stringify(data),
        success:function (data) {
            console.log(data);
        },
        error: function(xhr, status, error) {
        // handle error
      }
    });
How do I convert a curl GET request to a Zapier Webhook request?

How do I convert a curl GET request to a Zapier Webhook request?


By : Yestin
Date : March 29 2020, 07:55 AM
around this issue David here, from the Zapier Platform team. Great question!
Airtable handles request from Zapier a little differently than normal API requests. If you can, we recommend using the official Zapier app, since we take care of all that for you. If you don't do that, you've got two options:
Related Posts Related Posts :
  • access django session from a decorator
  • Multi-Threaded data insertion in MySQL using python
  • Making all variables accessible to namespace
  • What are the differences among sqlite3 from python2.5, pysqlite and apsw
  • Detect marker with opencv and python
  • Python ctypes and dynamic linking
  • Downloading a directory tree with ftplib
  • ImportError: No Module named simplejson
  • Pre-generating GUIDs for use in python?
  • `ipython` tab autocomplete does not work on imported module
  • Matching blank entries in django queryset for optional field with corresponding ones in a required field
  • Control VLC from Python in Windows
  • Return unicode string from python via ajax
  • Dynamically customize django admin columns?
  • Any way to add tabbed forms in django administration site?
  • Python / SQLite - database locked despite large timeouts
  • Encoding in XML declaration python
  • deletion of folders
  • Python Mindstorms RCX
  • Regex to split on successions of newline characters
  • Unicode filename to python subprocess.call()
  • Removing non-breaking spaces from strings using Python
  • Is there a way to backup everything in an app-engine blobstore?
  • Process a set of files from a source directory to a destination directory in Python
  • How to know if optparse option was passed in the command line or as a default
  • Rewriting a for loop in pure NumPy to decrease execution time
  • Comparing a time delta in python
  • Find next lower item in a sorted list
  • MySQLdb not INSERTING, _mysql does fine
  • Scipy Negative Distance? What?
  • What are the common patterns in web programming?
  • Percent signs in windows path
  • How to add a random number to a subsection of a numpy array?
  • How to generate all the values of an iterable besides the last few?
  • Searching by both class and range in XPath
  • Python code execution in Perl interpreter
  • Best Way to Include Variable in Python3
  • Serialize the @property methods in a Python class
  • What is the most platform- and Python-version-independent way to make a fast loop for use in Python?
  • Good way to edit the previous defined class in ipython
  • Bounced email on Google App Engine
  • Search jpeg files using python
  • Dynamically create class attributes
  • python unichr problem
  • Python beginner, strange output problem
  • Python: Finding a value in 1 list and finding that corresponding index in another list
  • can't install mysqlclient on mac os x mojave
  • Error indicates flattened dimensions when loading pre-trained network
  • how to replace underlines with words?
  • Adding through iteration
  • Use OpenCV on deployed Flask app (Heroku)
  • How to skip interstitial in a django view if a user hits the back button?
  • Any Naive Bayesian Classifier in python?
  • Python 2.5.2: remove what found between two lines that contain two concrete strings
  • Python 2.5.2 script that add "The function starts here" to all the functions of the files of a directory
  • HttpResponseRedirect question
  • Python socket error on UDP data receive. (10054)
  • Encoding issues with cloud ml
  • numpy.where - Weird behaviour: new elements spawning from nowhere?
  • I can't move my player in pygame, can you figure why?
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk