Integrating K2 with Exchange Online using OAuth with lesser permissions

K2 uses Exchange Web Services (EWS) and Azure app-only OAuth authentication for Exchange Online integration. The recommended way of configuring this integration is to use the Exchange Feature in K2 Management which requires the full_access_as_app application permission, and this permission requires the Azure Global Administrator role. Global Admin Consent is a requirement from Azure, and with this method there is no lesser permission to be set for an app-only implementation.

To be able to use lesser permissions, you need to manually set up an app in Azure with the EWS.AccessAsUser.All delegation permission and configure the corresponding OAuth resource in K2.

Use the information in this article to manually set up an app in Azure with the required minimum permissions, and configure K2 integration. The final section of this article is a demonstration of the steps needed to test the integration.

This article requires knowledge of Azure, SQL, and K2 OAuth configuration.

Prerequisites

  • The minimum TLS settings required for K2 to send mail. See the K2 and TLS 1.2 Support article for information.
  • Ensure your local Active Directory (AD) K2 Service account (this is the user account that runs the K2 Server) email address is the same as the K2 Service account email address in Microsoft 365 (Office 365/AAD). If you already have Azure Active Directory (AAD) configured, you can skip this.

    Other than the K2 Service Account, this article uses a recipient, Jane Doe, with the email address: janed@{your domain name}.onmicrosoft.com in the testing section. To use this recipient and follow the testing section exactly, make sure you have this email address in local AD and in AAD, otherwise use one of your own user accounts.
  • Exchange impersonation: the From Address account in K2 that sends the email (in the case of this article it is k2serviceonline@{your domain name}.onmicrosoft.com) requires impersonation rights.
    If you have the latest K2 Five cumulative update / fixpack for your version, you don't need to set up impersonation.

    To apply impersonation rights to the account, do the following.
    • Open Windows PowerShell ISE and paste this script into the coding area. Then edit your tenant admin email address (the XXXXXXX section below) and execute the script.
      Copy

      Impersonation PowerShell script

      Install-Module ExchangeOnlineManagement; # Accept prompts
      Import-Module ExchangeOnlineManagement; # Accept prompts
      Connect-ExchangeOnline -UserPrincipalName admin@XXXXXXX.onmicrosoft.com; # Will be redirected to login
      New-ManagementRoleAssignment -Name 'Demo App Impersonation' -Role:ApplicationImpersonation -User:k2serviceonline@XXXXXXX.onmicrosoft.com