Skip to main content

A Python SDK for handling FormSG webhooks.

Project description

FormSG Python SDK

PyPI version PyPI license PyPI pyversions PyPI status PyPI download total

This SDK provides convenient utilities for verifying FormSG webhooks and decrypting submissions in Python and Flask or Django.

Installation

pip install formsg

Usage

The SDK provides two main utility functions for handling FormSG webhook:

For convenience, the SDK implements a decrypt_django_request and decrypt_flask_request which returns the decrypted FormSG content from a Django/Flask request object directly.

Example with Flask

from formsg.webhook import decrypt_flask_request

from flask import Flask
from flask import jsonify
from flask import request

app = Flask(__name__)


@app.route('/formsg_webhook', methods=['POST'])
def formsg_webhook():
    decrypted = decrypt_flask_request(
        request,
        secret_key='xxx',
        webhook_uri='https://xxx.ngrok.io/formsg_webhook',  # we use ngrok to test our webhooks locally
    )

    return jsonify(decrypted)
#end def


if __name__ == '__main__':
    app.run(debug=True)
#end if

Contributions

If you find any issues or would like to contribute improvements, please feel free to raise them in this repository directly.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

formsg-0.1.3.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

formsg-0.1.3-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file formsg-0.1.3.tar.gz.

File metadata

  • Download URL: formsg-0.1.3.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for formsg-0.1.3.tar.gz
Algorithm Hash digest
SHA256 01269304f2de2c26cb67e7fe23051e0ae7a8e933de0520baa54db32834b92a94
MD5 f806363181a441ddc603f2123d4a9353
BLAKE2b-256 9958a5bf122db6ebd00fe88dcc7e7877536fe7928e3b41e1aecd14b4098153ae

See more details on using hashes here.

File details

Details for the file formsg-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: formsg-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for formsg-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f2448deadb12df3d42493d1c990999fad0ade3726eea70abbeac5b3e09ddd854
MD5 ebc05b85e7703109643fe9f978618f00
BLAKE2b-256 89385d5d29b5288331e9e1d3132893f625b2e409b9977ba6434239af07a51dac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page