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.2.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

formsg-0.1.2-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: formsg-0.1.2.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for formsg-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ec10b6ddbb3a126731de011bf9f1c3d94a4e62a464acbf29fa2248e2beb447d9
MD5 a59780b752a1b2cb6e8bd3f00b942457
BLAKE2b-256 5d313b8b3f5bbc5f6cb8638525b511863b245cd48004433bc7726392f9265803

See more details on using hashes here.

File details

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

File metadata

  • Download URL: formsg-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for formsg-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3077d1cd6c38c89204e95b69c40f77b5818eb1ad5cce0129370b2aea3fbea1e7
MD5 1b81020fac7c8685524f90097d6e7a70
BLAKE2b-256 78db07212d3448cb284b715aed27d3c4ecc641dbd133e5b85374e93929442fbb

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