# EWS - Authorize the Connection

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:
   * 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;

{% hint style="info" %}
**The following scopes must be used if you intend to use a shared mailbox**

* <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;
  {% endhint %}

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

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

4. Click 'Authorize'
5. 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/hlW9jKl7dcDggHAPhNU9/blobs/esWBpb29Dt0yoHlg781V/Screen%20Shot%202022-11-09%20at%2011.55.56%20AM.png" alt=""><figcaption></figcaption></figure>

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

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

&#x20;
