Search code examples
oauth-2.0google-appsgmail-apiservice-accounts

Gmail and Service Accounts


I'm finding conflicting information regarding using a OAuth 2.0 Service Account with Gmail. In theory, granting Gmail full read/write scope to a Service Account would mean that the application would have access to the email of all users of your Google Apps domain. Is it really possible to do this with a Service Account?


Solution

  • Take a look here. Once you obtain a service account credentials object impersonating an admin user you can use the above method to send a message from the account you want.

    Even more, as the From header is within the Message object you can send a message with a From that account has permission to send as.