We need to built a script that revokes access tokens generated by a user using G Suite (previous Google Apps for Work), especificaly the Directory API ([url removed, login to view])
The script must have a configuration file, which can determine: the JSON file to use, the name of the project at Google Developer Console, mail warning and location of the log output.
The script must be run in minimum time determined by the API, if possible, run the query every 5 minutes.
If a token generated is detected, it must revoke it and shoot an email message with the same information. Any runtime error must also be notified by email.
Additionally, we also appreciate analyze whether it is possible to generate a "whitelist" of allowed applications to not revoke OAuth token.
We provide testing environment and all information. The project deliverable must be open source.