Reputation: 509
I have already created a web platform to allow users within my organization with an @xxxx.com account to authorize their Google Accounts to send/receive email messages within the platform. The new messages reception is currently done manually by a "New Email" button, but I require an automated process running in the background to pull the email messages frequently.
I tried to do it with refresh_tokens for offline access and a periodic cron job but because there are a lot of users' accounts, that process would take too long to connect to each account, pull messages, and such. This may not work properly.
Is there any other way (using an API) to pull the users account email messages directly (something like an Audit or SuperAdmin account)?
Upvotes: 0
Views: 716
Reputation: 81336
Is there any other way (using an API) to pull the users account email messages directly (something like an Audit or SuperAdmin account)?
Yes, it is called G Suite Domain-Wide Delegation of Authority.
In summary, you create a service account and use that service account to access email for all users in your domain. You can also use this method to send email on behalf of users.
I have done this many times. An important tip is to follow the instructions "exactly" otherwise you will get permission errors.
Perform G Suite Domain-Wide Delegation of Authority
Upvotes: 1