Google Service Accounts

Grant EmailEngine access to all email accounts in the organization at once.

Click here to see other types of OAuth2 configurations

  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. Navigate to APIs & ServicesCredentials
  7. On the credential page, click the Manage service accounts link to create a service account.
  8. Create a new service account
  9. No need to grant any roles to that service account
  10. Select the newly generated service account
  11. Scroll down to Advanced settings
  12. Look for Domain-wide delegation
  13. Copy the client ID and click on the View Google Workspace admin console button_
  14. Search for API Controls
  15. Click on the Manage domain-wide delegation link
  16. Add new delegation
  17. Paste the client ID from the OAuth2 service account page
  18. Add https://mail.google.com as the OAuth2 scope
  19. Go back to the service account page and navigate to Keys
  20. Create a new key in the JSON format and save the generated key file
  21. Create a new Gmail Service Account application in EmailEngine
  22. Select the JSON configuration file for the service account
  23. Select IMAP and SMTP as base scopes and click on Register app to finish the process

Register an account with EmailEngine

Unlike other integration types, you can not add an email account as a service account through EmailEngine's web UI. Instead, you would have to use the API.

Change the email address and username to the email address you want to add. Change the OAuth2 provider with the ID of the OAuth2 app added to EmailEngine.

curl -XPOST "http://127.0.0.1:3000/v1/account" \
  -H "Authorization: Bearer ef3fdcbf9c9ca2432...." \
  -H "Content-type: application/json" \
  -d '{
    "account": "service",
    "name": "Andris Reinman",
    "email": "andris@kreata.ee",
    "oauth2": {
      "provider": "AAABkIKUkHcAAAAc",
      "auth": {
        "user": "andris@kreata.ee"
      }
    }
  }'