Search code examples
flaskgoogle-cloud-platformgoogle-apiservice-accounts

Making scheduled requests to Google APIs with service accounts


I have a flask website.

i would like the user to be able to schedule repeated requests for data from one of their Google accounts (let's say Gmail).

From within the website, the user would first authorize the application to access their private Gmail data. From then on, the application, would retrieve the user's Gmail data on a re-occurring basis, without needing to get authorization each time.

Is this possible? I know it would require a service account but can anyone point me in the direction of documentation that describes how this particular scenario might work.

Would such a scenario be allowed to persist long term? Or will their come a time when Google will require the user to reauthorize the application?


Solution

  • Correction, you should not use App Passwords. OAuth is the correct way to do it I believe:

    https://www.oauth.com/oauth2-servers/signing-in-with-google/

    Here's Google's docs on it, which is more specific to your need:

    https://developers.google.com/identity/protocols/oauth2