Connect Customer Engagement (on-premises) to Gmail accounts using OAuth 2.0

Follow these steps to set up server-side synchronization to send and receive email in Dynamics 365 Customer Engagement (on-premises) from Gmail accounts using OAuth 2.0 as the authorization mechanism.

Note

The Gmail OAuth email server profile requires version 9.1 or later and works for up to 100 users. Create multiple OAuth profiles to associate the same profile with multiple users.

An admin should perform the following procedures:

  1. Turn on IMAP or POP in Gmail
  2. Create a Google API Console project
  3. Set up OAuth consent
  4. Create an email server profile

A mailbox user should perform the following procedure:

Turn on IMAP or POP in Gmail

Create a Google API Console project

Create a project in the Google API Console using the Google account that will send and retrieve email.

  1. In the left navigation pane of the API Console, select OAuth consent screen.

  2. Select the user type:

    • Select Internal if you're using a GSuite admin tenant and are creating the app exclusively for your organization.
    • Select External if you're testing using a standalone Gmail account.
  3. Select Create.

  4. Enter the name of the app that's asking for consent.

  5. Enter the support address your users should email if they have questions about their consent.

  6. Under Authorized domains, select ADD DOMAIN and then enter your environment's top private domain name; for example, dynamics.com.

  7. Under Developer contact information, enter your email address.

  8. Select SAVE AND CONTINUE.

  9. In the left navigation pane, select Credentials.

  10. Select CREATE CREDENTIALS > OAuth client ID.

  11. Select or enter the following values:

    Setting Use
    Application type Web application
    Name The name of your web client
    Authorized JavaScript origins Your environment's URL; for example, https://contoso.crm.dynamics.com
    Authorized redirect URIs Your environment's URL with /_grid/cmds/dlg_gmailoauth.aspx appended to it; for example, https://contoso.crm.dynamics.com/_grid/cmds/dlg_gmailoauth.aspx
  12. Select CREATE.

  13. Note the client ID and client secret that appear on the following page. You'll use them in the next procedure.

    You can also find the client ID and secret under Credentials in the API Console.

  14. Under Test users, select ADD USER. Add a Gmail account to test the app with and remember to publish the app after you've tested and turned on the mailbox. Or, publish the app now and any Gmail account can be used to test with.

Create an email server profile

  1. Sign in to Customer Engagement (on-premises). In the upper-right corner of the web app, select the Settings gear icon, and then select Advanced settings.

  2. Select the arrow next to Settings, and then select Email Configuration.

  3. Select Email Server Profiles.

  4. Select the arrow next to New, and then select IMAP/SMTP Server.

  5. Enter a meaningful Name for the new profile.

  6. For Incoming Server Location, enter imap.gmail.com.

  7. For Outgoing Server Location, enter smtp.gmail.com.

  8. For Authenticate Using, select Gmail OAuth.

  9. For Client Id and Client Secret, enter the information you noted in the previous procedure.

  10. Expand Advanced.

  11. For Incoming Port, enter 993.

  12. For Outgoing Port, enter 587.

  13. Select Save & Close.

Set up and test the mailbox

  1. Sign in to Customer Engagement (on-premises). In the upper-right corner of the web app, select the Settings gear icon, and then select Advanced settings.

  2. Select the arrow next to Settings, and then select Email configuration > Mailboxes.

  3. Select and edit the mailbox to be used for server-side sync with Gmail.

  4. For Server Profile, select the email server profile that's associated with Gmail OAuth, created in the previous procedure.

  5. Make sure that both Incoming Email and Outgoing Email are set to Server-Side Synchronization or Email Router.

  6. Select Save.

  7. Select SignIn to Gmail. Sign in to and authorize the Gmail account you're using to test with.

  8. Select Save & Close.

  9. Select the mailbox, and then select TEST & ENABLE MAILBOX.

  10. Under Test Email Configuration, select which mailboxes to test. Select OK to run the test.

    You can view the results in the mailbox list or in the mailbox record.