> For the complete documentation index, see [llms.txt](https://docs.alemba.com/asm-eos-10.5/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.alemba.com/asm-eos-10.5/setup-and-configure-asm/setting-up-your-system/setup-email/setting-up-incoming-and-outgoing-email/configuring-exchange-web-services-ews/ews-authorize-the-connection.md).

# EWS - Authorize the Connection

Enable OAuth 2.0 Authentication

1. Enable the “Use OAuth 2.0 Authentication” checkbox in both the Incoming and Outgoing email server settings and click “Manage Token”&#x20;

{% hint style="info" %}
Both incoming and outgoing email servers can use the same token but each must be authorized separately to establish the respective connections&#x20;
{% endhint %}

2. Set the following values in the OAuth Token Details form&#x20;
   * Type: Microsoft Graph API&#x20;
   * Grant Type: authorization\_code&#x20;
   * Callback URL: Error! Hyperlink reference not valid.&#x20;
   * Authorization URL: [https://login.microsoftonline.com/{Azure Tenant ID}/oauth2/v2.0/authorize](https://login.microsoftonline.com/%7bAzure%20Tenant%20ID%7d/oauth2/v2.0/authorize)
   * Access Token URL: [https://login.microsoftonline.com/{Azure Tenant ID}/oauth2/v2.0/token](https://login.microsoftonline.com/%7bAzure%20Tenant%20ID%7d/oauth2/v2.0/token)&#x20;
   * Client ID: Value from the Azure App Registration&#x20;
   * Client Secret: The secret created for the App Registration&#x20;
3. The following scopes are required:&#x20;
   * <https://outlook.office365.com/Mail.ReadWrite&#x20>;
   * <https://outlook.office365.com/Mail.Send&#x20>;
   * <https://outlook.office365.com/User.Read&#x20>;
   * <https://outlook.office365.com/EWS.AccessAsUser.All> offline\_access&#x20;
4. The following scopes must be used if you intend to use a **shared mailbox**&#x20;
   * <https://outlook.office365.com/Mail.ReadWrite&#x20>;
   * <https://outlook.office365.com/Mail.Send&#x20>;
   * <https://outlook.office365.com/User.Read&#x20>;
   * <https://outlook.office365.com/Mail.ReadWrite.Shared&#x20>;
   * <https://outlook.office365.com/Mail.Send.Shared&#x20>;
   * <https://outlook.office365.com/EWS.AccessAsUser.All> offline\_access&#x20;

{% hint style="info" %}
Corresponding permissions for these scopes *may* need to be added manually to the App Registration.
{% endhint %}

<figure><img src="https://content.gitbook.com/content/6Ckybwmt0tmi7y8MgYX4/blobs/V8vxsN9K86zAJUDaE5jc/Screen%20Shot%202022-11-09%20at%2011.54.50%20AM.png" alt=""><figcaption></figcaption></figure>

5. Click 'Authorize'
6. A pop up window will appear for you to enter the Exchange credentials and then authorize the connection

<figure><img src="https://content.gitbook.com/content/6Ckybwmt0tmi7y8MgYX4/blobs/ILsIyPF7mCSG50L4Up6O/Screen%20Shot%202022-11-09%20at%2011.55.56%20AM.png" alt=""><figcaption></figcaption></figure>

<figure><img src="https://content.gitbook.com/content/6Ckybwmt0tmi7y8MgYX4/blobs/2FWxYIoiFbl5g9iCVkh3/Screen%20Shot%202022-11-09%20at%2011.56.20%20AM.png" alt=""><figcaption></figcaption></figure>

7. When the authorization process is complete, the popup will close.  The OAuth Token Details dialog should close shortly thereafter.&#x20;

&#x20;
