I need to monitor a Gmail INBOX for new emails and when that happens, a push notification should go a webhook hosted in flask app, so I can take action based on the new email.
How can this be achieved using Pub/Sub? If it is already addressed somewhere else, please share the reference.
I did the following
- Created and deployed the flask app to GAE
- Obtained the credentials JSON by enabling and configuring Gmail API
- Tested the connectivity and is working fine.
- Created a topic and a subscriber
What I am not sure is how to link this to the webhook URL and actively listen for any new emails.
Follow Google's documentation
Note that it says
I suggesting using Cloud Scheduler to invoke an App Engine handler that calls
watchdaily or every 7 daysSince you're trying to read gmails, you'll need authorization via OAuth 2.0 credentials. If your App is set to external users and isn't published, your token will expire every 7 days (see doc)