Gmail API

EmailEngine uses Gmail API as the messaging backend.

Click here to see other types of OAuth2 configurations or here for a tutorial.

  1. Open Google Cloud Console
  2. Create a new project
  3. Select the created project
  4. Navigate to APIs & ServicesEnabled APis and services
  5. Search for "Gmail API" and enable it
  6. Search for "Cloud Pub/Sub" and enable it
  7. Navigate to APIs & ServicesOAuth consent screen
  8. Choose your application type. "Internal" is valid only for email accounts in the same organization. "External" supports all Gmail accounts but requires extensive validation. In this tutorial, we use "Internal."
  9. Fill out the app-related fields in the "OAuth2 consent screen" form. Use the URL of your EmailEngine instance as the "Application home page."
  10. Click on Save and continue to get to the scopes form
  11. Click on Add or remove scopes and look for https://www.googleapis.com/auth/gmail.modify, add it and click Save and continue
  12. Navigate to APIs & ServicesCredentials
  13. Create new OAuth client ID
  14. Select Web application as the app type
  15. Add EmailEngine's URL as the authorized origin
  16. Use EmailEngine's URL with the /oauth path as the Authorized redirect URI
  17. Click Create to finish the application
  18. In the opened credentials screen, download credentials in JSON format
  19. In the credential page, click the Manage service accounts link to create a webhook service account. With Gmail API, EmailEngine needs to use the Cloud Pub/Sub API to retrieve email updates
  20. Create a new service account
  21. Grant the Pub/Sub Admin role to the service account. This is needed because EmailEngine needs to set up pubsub queues and give Gmail permissions to publish to that queue.
  22. Select the newly generated service account and navigate to Keys
  23. Create a new key in the JSON format and save the generated key file
  24. Create a new Gmail Service Account application in EmailEngine
  25. Select the JSON configuration file for the Pub/Sub service account
  26. Select Pub/Sub as base scopes and click on Register app
  27. Create a new Gmail OAuth2 application in EmailEngine
  28. Select the JSON file to autofill application configuration details
  29. Choose Gmail API as the base scope
  30. Choose the previously generated Gmail Service Account as the webhook handler for this app. (You can only choose a service account app with the same Google Cloud project ID.)
  31. Click Register app to finish the process