> For the complete documentation index, see [llms.txt](https://docs.teleskope.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.teleskope.ai/connectors/saas/filesharing/sharepoint-and-onedrive.md).

# M365 - Sharepoint/OneDrive

## Requirements

* Within Azure, an Entra App was created as described [here](https://docs.teleskope.ai/connectors/clouds/azure.md). Microsoft 365 tenants authenticate with a certificate that Teleskope generates during enrollment, so you do not need a client secret for Microsoft 365. Other Azure connectors that reuse the same app may still need one.
* Within Teleskope, you have a Teleskope Account with the Admin role

## Integration

{% stepper %}
{% step %}

#### Grant application permissions

Navigate to your App Registration, then Manage -> API Permissions. Add each permission in the table as an *Application permission* (not Delegated). Each one needs admin consent.

{% hint style="info" %}
**ActivityFeed.Read** is not in Microsoft Graph. Add a permission > Microsoft APIs > Office 365 Management APIs > Application permissions.
{% endhint %}

{% hint style="info" %}
SharePoint **Sites.Read.All** is a separate permission from Microsoft Graph **Sites.Read.All**. Microsoft Graph does not expose SharePoint site group membership, so Teleskope reads it from the SharePoint REST API, which only accepts certificate-authenticated app tokens.
{% endhint %}

| API                        | Permission                               | Required or optional       | What it enables                                                                                                                                               |
| -------------------------- | ---------------------------------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Microsoft Graph            | **Directory.Read.All**                   | Required                   | Read the tenant's domains and the members of Entra directory roles, so access can be mapped to people                                                         |
| Microsoft Graph            | **ExternalUserProfile.Read.All**         | Required                   | Expected by the connector health check; grant it with the other required Graph permissions                                                                    |
| Microsoft Graph            | **Files.Read.All**                       | Required                   | Read files and file metadata for discovery, scanning, and classification                                                                                      |
| Microsoft Graph            | **Group.Read.All**                       | Required                   | List groups used in file and site access                                                                                                                      |
| Microsoft Graph            | **GroupMember.Read.All**                 | Required                   | Read group membership, including members of nested groups                                                                                                     |
| Microsoft Graph            | **RoleManagement.Read.All**              | Required                   | Expected by the connector health check; grant it with the other required Graph permissions                                                                    |
| Microsoft Graph            | **SharePointTenantSettings.Read.All**    | Required                   | Read the tenant sharing setting that decides whether an Anyone link grants access                                                                             |
| Microsoft Graph            | **Sites.Read.All**                       | Required                   | List SharePoint sites and their document libraries to crawl                                                                                                   |
| Microsoft Graph            | **User.Read.All**                        | Required                   | Read user names and email addresses to map who has access                                                                                                     |
| SharePoint                 | **Sites.Read.All**                       | Optional                   | Read SharePoint site group membership (Owners, Members, and Visitors). Requires the enrollment certificate. Without it, Teleskope records the group name only |
| Office 365 Management APIs | **ActivityFeed.Read**                    | Required for live activity | The live feed of SharePoint and OneDrive activity from Microsoft, about the last 7 days. Without it, that feed collects nothing                               |
| Microsoft Graph            | **AuditLogsQuery-SharePoint.Read.All**   | Required for history       | SharePoint activity from before live collection started. Grant together with **AuditLogsQuery-OneDrive.Read.All**                                             |
| Microsoft Graph            | **AuditLogsQuery-OneDrive.Read.All**     | Required for history       | OneDrive activity from before live collection started. Grant together with **AuditLogsQuery-SharePoint.Read.All**                                             |
| Microsoft Graph            | **SensitivityLabels.Read.All**           | Optional                   | List the tenant's Purview sensitivity labels so Policy Maker can offer them                                                                                   |
| Microsoft Graph            | **InformationProtectionPolicy.Read.All** | Optional                   | Read the tenant's information protection labels from the legacy catalog when the modern catalog is denied                                                     |
| Microsoft Graph            | **Files.ReadWrite.All**                  | Optional                   | Policy Maker remediation: apply or remove a sensitivity label, quarantine a file, delete a file, or remove a sharing permission                               |

The two history permissions are required together. The history load queries SharePoint and OneDrive in one request. Teleskope's connector health check does not recognize the broader Microsoft Graph permission **AuditLogsQuery.Read.All**, so grant these two specific permissions.

The history load is a separate job your Teleskope contact runs after both permissions are granted. Turning activity collection on does not start it. It runs once and loads up to about 180 days of SharePoint and OneDrive activity from before collection started, stopping 24 hours before live collection began.

A missing history permission is not an error for the live feed. Microsoft answers "access denied" to the history search, so the history load cannot start. Grant both history permissions before that load is scheduled with your Teleskope contact. Without the history load, activity history starts when Teleskope began collecting activity.

Policy Maker actions that apply labels, quarantine files, or delete files need **SensitivityLabels.Read.All**, **InformationProtectionPolicy.Read.All**, and **Files.ReadWrite.All** together. If you enable actions that apply or remove Purview sensitivity labels, also enable [metered APIs and services in Microsoft Graph](https://learn.microsoft.com/en-us/graph/metered-api-setup?tabs=azurecloudshell) for the Teleskope app registration. Microsoft treats the SharePoint and OneDrive `assignSensitivityLabel` API as a metered Graph API, so Graph permissions and admin consent alone are not sufficient for that action.

Purview unified audit logging must also be on for activity; see [SharePoint and OneDrive activity](#sharepoint-and-onedrive-activity).

Lastly, grant admin consent to all of the permissions.
{% endstep %}

{% step %}

#### Enroll the tenant in Teleskope

1. Navigate to **Settings > Connectors > Microsoft 365** and click **Enroll**.
2. Enter your Tenant ID, a Tenant Name, and the app's Client ID, then click **Next**.
3. Click **Generate certificate**, then **Download .cer**.
   {% endstep %}

{% step %}

#### Upload the certificate to Entra

1. In the Entra admin center, open **App registrations** and select the Teleskope app.
2. Open **Certificates & secrets > Certificates** and upload the `.cer` file.
3. Confirm the thumbprint Entra shows matches the one in Teleskope.
4. Back in Teleskope, click **Activate**, then **Done**.

Entra can take a few minutes to accept a new certificate. If activation fails, wait and try again.

Teleskope holds the private key; only the public certificate leaves Teleskope. To rotate, go to **Settings > Connectors > Microsoft 365**, open the tenant row's menu and click **Edit**, then click **Next**. Click **Rotate certificate**, download the new `.cer`, and repeat this step. Keep the previous certificate registered in Entra until Teleskope confirms its services have restarted; running services keep using the previous certificate until then.
{% endstep %}
{% endstepper %}

## SharePoint and OneDrive activity

{% hint style="info" %}
This feature is optional to turn on. Work with your Teleskope contact to enable file activity tracking and "Last Accessed" data. **ActivityFeed.Read** and Purview unified audit logging are required for it.
{% endhint %}

### Required permissions

Activity uses the table in [Grant application permissions](#grant-application-permissions). **ActivityFeed.Read** is required for the live feed. **AuditLogsQuery-SharePoint.Read.All** and **AuditLogsQuery-OneDrive.Read.All** are required together for the history load. Add each as an *Application permission* (not Delegated). Each one needs admin consent.

A missing history permission is not an error for the live feed. The history load does not start when collection is turned on. Without the history load, history starts when Teleskope began collecting activity, and the live feed is unaffected.

### Audit logging activation

Microsoft Purview unified audit logging must be on; when it is off, Microsoft returns no activity rather than an error.

1. Open the [Microsoft Purview portal](https://compliance.microsoft.com) and navigate to **Audit**.
2. If prompted, click **Start recording user and admin activity** to enable audit logging.

Alternatively, verify using Exchange Online PowerShell and confirm the result is `True`:

```powershell
Get-AdminAuditLogConfig | Format-List UnifiedAuditLogIngestionEnabled
```

### Verification

Share the following with your Teleskope contact:

1. A screenshot of the granted API permissions (showing admin consent has been granted)
2. A screenshot confirming audit logging is enabled in the Purview portal

Microsoft can take up to 12 hours to deliver the first batch of activity. The activity feed covers only the last 7 days. Without the history load, history starts when Teleskope began collecting activity, and the live feed is unaffected.

### Data scope

Teleskope reads audit records only (the user or app, the action, the time, the site and file path, and the client IP address and application) and no file contents. Access is read-only. **ActivityFeed.Read** covers Microsoft's whole audit feed; Teleskope subscribes only to SharePoint and OneDrive activity.
