> For the complete documentation index, see [llms.txt](https://docs.aisera.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aisera.com/aisera-platform/adding-data-to-your-tenant/integrations-and-data-sources/connectors/office-365.md).

# Office 365

Configure Office 365 integration - first in Microsoft Azure, then in Aisera Admin for user and user group learning.&#x20;

**Note**: Ensure that you copy the Client Secret as soon as you create it in Azure as the value will be masked after creation, and you might not be able to retrieve the full secret again.

### Prerequisites

Ensure that you have the following:

* Access to Azure portal with permission to register applications and grant Microsoft Graph application permissions. For Azure portal, see [Login to Azure](https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize?client_id=c44b4083-3bb0-49c1-b47d-974e53cbdf3c\&scope=https%3A%2F%2Fmanagement.core.windows.net%2F%2F.default%20openid%20profile%20offline_access\&redirect_uri=https%3A%2F%2Fportal.azure.com%2Fauth%2Flogin%2F\&client-request-id=01a0a441-40aa-7a2a-a059-5f185effeb6f\&response_mode=fragment\&client_info=1\&clidata=1\&nonce=01a0a441-40ab-7d17-989e-a2b3b05defa2\&state=eyJpZCI6IjAxYTBhNDQxLTQwYWItNzVlZi05MTExLWNkNmJmZTdjNjllYiIsIm1ldGEiOnsiaW50ZXJhY3Rpb25UeXBlIjoicmVkaXJlY3QifX0%3D\&claims=%7B%22id_token%22%3A%7B%22signin_state%22%3A%7B%22essential%22%3Afalse%7D%2C%22login_hint%22%3A%7B%22essential%22%3Afalse%7D%7D%7D\&x-client-SKU=msal.js.browser\&x-client-VER=5.18.0\&response_type=code\&code_challenge=ENPaagkfsWmnrufiv0LHom01V3Ncc1bzKh1UDjaJGZ0\&code_challenge_method=S256\&site_id=501430\&instance_aware=true).
* Able to sign in and access Aisera Admin portal.
* Are aware about which Office 365 tenant will be connected.

### Understanding the configurations

The following table provides a brief information on what components would you be configuring and where it will be used:

<table><thead><tr><th width="183.629638671875">Component</th><th>Configuration</th><th>Usage</th></tr></thead><tbody><tr><td>Azure application</td><td>App registration, client ID, tenant ID, client secret, Graph permissions</td><td>Required for Office 365 authentication</td></tr><tr><td>Aisera integration</td><td>Endpoint, tenant ID, client ID, client secret</td><td>Connects Aisera to Microsoft Graph</td></tr><tr><td>Office 365 data source</td><td>User and User Group functions, beta API context</td><td>Supports ingestion and learning for supported entities</td></tr></tbody></table>

### Procedure

#### Create and configure the Azure application

1. Log in to the Azure portal.\
   See [Login to Azure](https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize?client_id=c44b4083-3bb0-49c1-b47d-974e53cbdf3c\&scope=https%3A%2F%2Fmanagement.core.windows.net%2F%2F.default%20openid%20profile%20offline_access\&redirect_uri=https%3A%2F%2Fportal.azure.com%2Fauth%2Flogin%2F\&client-request-id=01a0a441-40aa-7a2a-a059-5f185effeb6f\&response_mode=fragment\&client_info=1\&clidata=1\&nonce=01a0a441-40ab-7d17-989e-a2b3b05defa2\&state=eyJpZCI6IjAxYTBhNDQxLTQwYWItNzVlZi05MTExLWNkNmJmZTdjNjllYiIsIm1ldGEiOnsiaW50ZXJhY3Rpb25UeXBlIjoicmVkaXJlY3QifX0%3D\&claims=%7B%22id_token%22%3A%7B%22signin_state%22%3A%7B%22essential%22%3Afalse%7D%2C%22login_hint%22%3A%7B%22essential%22%3Afalse%7D%7D%7D\&x-client-SKU=msal.js.browser\&x-client-VER=5.18.0\&response_type=code\&code_challenge=ENPaagkfsWmnrufiv0LHom01V3Ncc1bzKh1UDjaJGZ0\&code_challenge_method=S256\&site_id=501430\&instance_aware=true).
2. Open **Azure Active Directory**.
3. Click **App registrations** > **New registration**.
4. Enter a name for the application and create it.
5. Open the created application from **App registrations**.
6. In the **Overview** page, save the following values:
   * **Application (client) ID**
   * **Directory (tenant) ID**\
     **Note:** These values will be used later in the Aisera Office 365 integration form.

#### Get the Microsoft Graph API endpoint

1. In the Azure application, click **Overview > Endpoints**.
2. Copy the **Microsoft Graph API** endpoints.<br>

This endpoint is entered in Aisera as the Office 365 API endpoint.

#### Create a client secret

1. Log in to the Azure portal.\
   See [Login to Azure](https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize?client_id=c44b4083-3bb0-49c1-b47d-974e53cbdf3c\&scope=https%3A%2F%2Fmanagement.core.windows.net%2F%2F.default%20openid%20profile%20offline_access\&redirect_uri=https%3A%2F%2Fportal.azure.com%2Fauth%2Flogin%2F\&client-request-id=01a0a441-40aa-7a2a-a059-5f185effeb6f\&response_mode=fragment\&client_info=1\&clidata=1\&nonce=01a0a441-40ab-7d17-989e-a2b3b05defa2\&state=eyJpZCI6IjAxYTBhNDQxLTQwYWItNzVlZi05MTExLWNkNmJmZTdjNjllYiIsIm1ldGEiOnsiaW50ZXJhY3Rpb25UeXBlIjoicmVkaXJlY3QifX0%3D\&claims=%7B%22id_token%22%3A%7B%22signin_state%22%3A%7B%22essential%22%3Afalse%7D%2C%22login_hint%22%3A%7B%22essential%22%3Afalse%7D%7D%7D\&x-client-SKU=msal.js.browser\&x-client-VER=5.18.0\&response_type=code\&code_challenge=ENPaagkfsWmnrufiv0LHom01V3Ncc1bzKh1UDjaJGZ0\&code_challenge_method=S256\&site_id=501430\&instance_aware=true).
2. Navigate to **Certificates & secrets**.
3. Select **New client secret**.
4. Create the secret.
5. Immediately copy the generated secret value and store it securely.\
   **Important**: Do not ignore this step as the secret key will be masked and you will have to create a new one later.

#### Configure Microsoft Graph API permissions

Set the required Microsoft Graph application permissions for the application:

1. In the Azure portal, open **API permissions**.
2. Select **Add a permission**.
3. Choose **Microsoft Graph > Application permissions**.
4. Add the following permissions:
   1. **Directory.ReadWrite.All**
   2. **Group.ReadWrite.All**

Complete the required admin consent process in Azure if your organization requires approval for application permissions.

## Configurations in Aisera Admin

This sections lists the various configurations that you must perform in the Aisera Admin such as creating an integration and data source for adding a new Office 365 connector.

### Create and configure an integration

Use the following instructions to create an Integration for Office 365 connector.

1. Log in to Aisera Admin, and navigate to **Settings > Integration**.
2. Click the **New Integration** button on the top right.
3. Search for **Office 365**.
4. Select **Office 365** and click **Next**.\
   A **Configuration** screen appears.
5. In the **Name** field, enter a name for your Office 365 integration.
6. In the **Endpoint** field, enter the Microsoft Graph API endpoint.\
   To get the endpoint, log in to the Azure application, and navigate to **Overview > Endpoints**.
7. The **Public** check box is enabled by default.\
   (Optional) You can clear this check box if you want to restrict the integration usage to only within your network firewall.
8. Click **Next**.&#x20;
9. In the **Client Id** field, enter Application (client) ID.\
   To get the Application (client) ID, log in to the Azure application, and click **Overview**.
10. In the **Client Secret** field, enter the Client Secret value.\
    To get this value, log in to the Azure application, and click **Overview**.
11. In the **Azure Tenant ID** field, enter the Directory (tenant) ID.\
    To get the tenant ID, log in to the Azure application, and navigate to **Certificates > Secrets**.
12. Click **Ok**.

After you have updated these values, the Office 365 integration connection is configured in Aisera Admin.

### Create and configure a data source

Use the following instructions to create a data source for Office 365 connector.

1. Log in to Aisera Admin, and navigate to **Settings > Data Sources**.
2. Click the **New Data Source** button on the top right.
3. Search for **Office 365**.
4. Select **Office 365** and click **Next**.\
   A **General** screen appears.
5. In the **Name** field, enter a name for your Office 365 data source.
6. Click the **Functions** drop-down menu, and select **User** and **User group.** \
   **Note**: The Office 365 connector currently supports **User** and **User group** functions in this setup.
7. Click the **Integration** drop-down menu and select the Office 365 integration that you previously created.
8. Click the **Schedule** drop-down menu and select a time plan.\
   For example, if you want the data ingestion to be executed manually, select **On demand**.
9. Click **Next**.\
   A configuration screen appears.
10. In the **Context Parameters** field, enter the following JSON:\
    { \
    "context\_api\_version": "beta" \
    }

The value `beta` in the JSON refers to the Microsoft Graph API version used for this configuration. For more details on API versions and support, review the [Microsoft Graph documentation](https://learn.microsoft.com/en-us/graph/).

### Run ingestion

After the integration and data source are configured, you can run ingestion.

* Verify the integration fields are saved correctly.
* Confirm the data source includes **User** and **User Group**.
* Confirm the configuration JSON includes `"context_api_version": "beta"`
* Start ingestion.

### Validation checklist

Review the following validation checklist in order to ensure the ingestion was successful:

* Azure application created
* Client ID copied
* Tenant ID copied
* Microsoft Graph API endpoint copied
* Client secret created and saved securely
* **Directory.ReadWrite.All** permission added
* **Group.ReadWrite.All** permission added
* Office 365 integration configured in Aisera Admin
* Office 365 data source created
* User and User Group functions selected
* Beta API configuration added
* Ingestion started

## Troubleshooting notes

| Issue                                               | Likely cause                                                                | Recommended action                                                                      |
| --------------------------------------------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| Authentication fails                                | Incorrect tenant ID, client ID, or client secret                            | Re-copy values from Azure and verify there are no extra spaces                          |
| Secret does not work                                | Wrong value copied or secret was not saved at creation time                 | Create a new client secret and update the integration                                   |
| Data access is incomplete                           | Required Microsoft Graph permissions are missing or consent was not granted | Review API permissions and complete the required approval flow in Azure                 |
| User or group ingestion does not behave as expected | Missing beta API configuration                                              | Confirm the data source configuration includes the JSON entry for `context_api_version` |

### References

* [O365 Integration](https://automationanywhere.atlassian.net/wiki/spaces/ENGG/pages/7328983409)
* [Microsoft Azure](https://portal.azure.com/)
