# Configuring Microsoft 365 (Exchange Online via EWS)

Source: https://help.sendent.com/sendent-nextcloud-workspace/nextcloud-for-exchange/exchange-setup-guide

This guide explains how to configure **Exchange Web Services (EWS)** authentication for Exchange Online (Microsoft 365) to support the Nextcloud Exchange Connector workflow.

[**Microsoft 365 and want to use EWS? Please read this!**](https://techcommunity.microsoft.com/blog/exchange/notes-from-the-field-testing-ewsallowedappids-safely/4548568)



**Note:**

Unlike On-Premise environments that use Service Accounts with Kerberos or Basic Authentication, Microsoft 365 requires modern **OAuth 2.0 app-only authentication**. To achieve this, you must register the connector as an application in **Microsoft Entra ID** (formerly Azure AD).



## Pre-requirements

Before you begin the app registration process, ensure you have the following:

1. **Administrative Access:** You must have Global Administrator or Application Administrator privileges in your **Microsoft Entra ID** tenant to grant organizational consent for the required API permissions.
2. **Active Microsoft 365 Tenant:** An active Microsoft 365 subscription with Exchange Online mailboxes provisioned.

### Step 1. Register the Application in Microsoft Entra

**Why this is needed:** Registering the application generates a unique Application (client) ID and Directory (tenant) ID. These identifiers act as the username and domain for your connector to securely communicate with the Microsoft 365 cloud.

1. Open a browser and log in to the [Microsoft Entra admin center](https://entra.microsoft.com/).
2. Navigate to **Entra ID** &gt; **App registrations** (located in the left sidebar).
3. Click **New registration** at the top of the page.

![image.png](https://cdn.eniston.com/bases/0f220f4b-6749-49a9-8420-4a32e6d205f7/attachments/1775128752_69ce50b03ed68.png)

4. Fill out the registration form. with the following parameters:
    
    
    - Set **Name** to a friendly name for your app.
    - Set **Supported account types** to the **Single Tenant Only**.
    - **Redirect URI:** Leave this field empty.

5. Click **Register**.

![image.png](https://cdn.eniston.com/bases/0f220f4b-6749-49a9-8420-4a32e6d205f7/attachments/1775132293_69ce5e8571c23.png)

6. Once the app is created, you will be redirected to the **Overview** page. **Copy and save** the following identifiers; you will need them later:
    
    
    - `Application (client) ID` (This will be your **AppId**)
    - `Directory (tenant) ID` (This will be your **TenantId**)

![image.png](https://cdn.eniston.com/bases/0f220f4b-6749-49a9-8420-4a32e6d205f7/attachments/1775132677_69ce600516ab4.png)

## Step 2. Configure Permissions for App-only Access

**Why this is needed:** The connector operates as a background daemon (server-to-server) without a signed-in user present. It requires "Application permissions" with the `full_access_as_app` role to impersonate users and sync their calendars and contacts.

1. In your app registration menu, navigate to **Manage** &gt; **API permissions**.

![image.png](https://cdn.eniston.com/bases/0f220f4b-6749-49a9-8420-4a32e6d205f7/attachments/1775132771_69ce6063e16ee.png)

2. Click **Add a permission** &gt; **APIs my organization uses** and search for **Office 365 Exchange Online**.

![image.png](https://cdn.eniston.com/bases/0f220f4b-6749-49a9-8420-4a32e6d205f7/attachments/1775133095_69ce61a7760f7.png)

3. Select **Application permissions**.

![image.png](https://cdn.eniston.com/bases/0f220f4b-6749-49a9-8420-4a32e6d205f7/attachments/1775133175_69ce61f7c49f1.png)

4. Check the box `full_access_as_app` and click **Add permissions**.

![image.png](https://cdn.eniston.com/bases/0f220f4b-6749-49a9-8420-4a32e6d205f7/attachments/1775133345_69ce62a137565.png)

**Warning: Grant Admin Consent**

Adding the permission is not enough. You **must** click the **Grant admin consent for \[Your Organization\]** button on the API permissions page and accept the prompt.

If the status does not show a green checkmark, **Microsoft 365 will deny all synchronization requests from the connector.**



### Step 3. Create a Client Secret

**Why this is needed:** The Client Secret acts as the password for your newly registered application, proving its identity to Microsoft Entra ID when requesting an access token.

1. Navigate to **Manage** &gt; **Certificates &amp; secrets**.
2. Under the **Client secrets** tab, click **New client secret**.
3. Add a description and choose an expiration period, then click **Add**.

![image.png](https://cdn.eniston.com/bases/0f220f4b-6749-49a9-8420-4a32e6d205f7/attachments/1775133606_69ce63a6eb3ae.png)

4. **Immediately copy the** `Value` of the client secret. **You will not be able to view it again once you leave the page.**

![image.png](https://cdn.eniston.com/bases/0f220f4b-6749-49a9-8420-4a32e6d205f7/attachments/1775133977_69ce651926362.png)

### Step 4. Save Credentials for Installation

You have successfully generated the required Microsoft 365 access keys. Put them on an EWS sync client in your .env file.

Configuration mapping cheat sheet

```bash
EventSyncClients__0__Identifier=ews
EventSyncClients__0__Provider=Ews
EventSyncClients__0__Settings__ExchangeType=1
EventSyncClients__0__Settings__TenantId=your-directory-tenant-id-here
EventSyncClients__0__Settings__AppId=your-application-client-id-here
EventSyncClients__0__Settings__ClientSecret=your-client-secret-value-here

EventSyncClients__1__Identifier=dav
EventSyncClients__1__Provider=Dav
EventSyncClients__1__Settings__BaseUrl=https://cloud.example.com/
EventSyncClients__1__Settings__ServiceUsername=sync-admin
EventSyncClients__1__Settings__ServicePassword=your-password
EventSyncClients__1__Settings__SharedSecret=your-shared-secret

EventSync__Pairs__0__SourceClientId=ews
EventSync__Pairs__0__TargetClientId=dav
EventSync__CalendarPriorityOrder__0=ews
EventSync__CalendarPriorityOrder__1=dav
```

`admins.json` is optional. Use it only if you need several admin identities for throttling. A single app registration on the client is enough to start.



## Next Step

[Configuring Nextcloud](https://help.sendent.com/sendent-nextcloud-workspace/nextcloud-for-exchange/configuring-nextcloud)
