A quick introduction to webhooks.
Several methods exist to synchronize data between services:
The first is the easiest, but wastes the most bandwidth and compute resources. The second is possible, but there may be intermittent issues, e.g. server gives up after a set number of failures, resulting in missed updates. The last is possible, requires the server itself to collect changes, but we can ensure the service will be ready for data queried from the server.
In the context of Google API, this corresponds to:
Setting up a webhook server is straightforward, this example in Python:
import flask from flask import request, Response app = flask.Flask(__name__) @app.route("/webhook", methods=["POST"]) def webhook(): print(request.json) return Response( "Success!\n", headers={"X-Goog-Channel-ID": 1,}, status=200, mimetype="text/plain", ) app.run(host="localhost", port=8182, debug=True)
and then of course the venerable reverse proxy to pipe to the HTTP(S) port. Testing can be done with curl
or other tools of choice, e.g. Postman.