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='o4qGJ/AFpmToTOpqptMyTsV3WofQjD7dX6cpVZ7RwNA=',
        webhook_uri='https://90da680eb8fa.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.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

formsg-0.1.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for formsg-0.1.1.tar.gz
Algorithm Hash digest
SHA256 159982f1be7594cbb0763599d319707d40bb566ae4bdf0833b91e6259611260a
MD5 1421a5c668d616d933774000b9b34ed4
BLAKE2b-256 d2cf207488ffbc698d49f9b73d5729289ac0f0f0fd2a8df440b979c00b7525bb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: formsg-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.2 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/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for formsg-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 133f5271e659ee94bd99e73d479ba6d92b8a294aadb06ecc3a3df379f28691d7
MD5 e3601a6e2b0b6ba7ca3824059962130c
BLAKE2b-256 9f803f5f39f16f03581897b7c1f413b3652816e0936eaa2225a2ba163890d5b9

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