Skip to content

Instantly share code, notes, and snippets.

@spasiu
Created May 19, 2016 18:39
Show Gist options
  • Select an option

  • Save spasiu/1a422ce09d36ecb8749f82f076b853af to your computer and use it in GitHub Desktop.

Select an option

Save spasiu/1a422ce09d36ecb8749f82f076b853af to your computer and use it in GitHub Desktop.
example of setting a webhook via the Smooch API in Python
import jwt # https://github.com/jpadilla/pyjwt
import requests # http://docs.python-requests.org/en/master/
SECRET = 'your_secret'
KID = 'your_key'
token = jwt.encode({'scope': 'app'}, SECRET, algorithm='HS256', headers={'kid': KID, 'alg': 'HS256'})
response = requests.get(url="https://app.smooch.io/v1/webhooks",
headers={'content-type': 'application/json', 'authorization': 'Bearer ' + token },
json={'target' : 'http://example.com/hooks'})
print(response.json());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment