> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/adapters/m/microsoft-o365.md).

# Microsoft o365

Microsoft 365 (o365) is the productivity suite of Microsoft. OctoXLabs reads users and subscribed licenses from Microsoft Graph. It can also add license assignments and directory (admin) role assignments to each user.

## Use cases

* List Microsoft 365 users.

```
Adapters = microsoft-o365
```

* Find Microsoft 365 users in a given mail domain.

```
Adapters = microsoft-o365 AND Domain = example.com
```

## Before you begin

### Network

| Source              | Destination               | Port | Protocol |
| ------------------- | ------------------------- | ---- | -------- |
| OctoXLabs connector | login.microsoftonline.com | 443  | HTTPS    |
| OctoXLabs connector | graph.microsoft.com       | 443  | HTTPS    |

### Required permissions

| Scope or role                                                                                                                 | Permission | Needed for                                                             |
| ----------------------------------------------------------------------------------------------------------------------------- | ---------- | ---------------------------------------------------------------------- |
| Users.Read.All (Microsoft Graph, application)                                                                                 | Read       | User profiles                                                          |
| Directory.Read.All                                                                                                            | Read       | Directory data                                                         |
| Sites.Read.All                                                                                                                | Read       | SharePoint sites (listed as commonly used in the instructions)         |
| Files.Read.All                                                                                                                | Read       | Files the app can access (listed as commonly used in the instructions) |
| LicenseAssignment.Read.All, or Directory.Read.All, Directory.ReadWrite.All, Organization.Read.All, Organization.ReadWrite.All | Read       | Fetch Users Licenses                                                   |
| RoleManagement.Read.Directory, or Directory.Read.All                                                                          | Read       | Fetch Admin Roles                                                      |

Add only the permissions your use case needs.

## Create credentials in Microsoft o365

{% stepper %}
{% step %}

### Register an application

Register an app in Microsoft Entra ID and note the Application (client) ID and the Tenant ID.
{% endstep %}

{% step %}

### Create a client secret

Go to Certificates & Secrets and select New client secret. Provide a description and expiration, select Add, and copy the secret value at once.
{% endstep %}

{% step %}

### Add API permissions

Open API Permissions > Add a permission, select Microsoft Graph, then Application permissions. Add the permissions from the table above.
{% endstep %}

{% step %}

### Grant admin consent

Select Grant admin consent to approve the permissions for the organization.
{% endstep %}
{% endstepper %}

## Connection parameters

| Parameter                                    | Required | Type    | Default | Description                                                                        |
| -------------------------------------------- | -------- | ------- | ------- | ---------------------------------------------------------------------------------- |
| Client ID (`client_id`)                      | Yes      | String  |         | Application (client) ID.                                                           |
| Client Secret (`client_secret`)              | Yes      | String  |         | Client secret value.                                                               |
| Tenant ID (`tenant_id`)                      | Yes      | String  |         | Directory (tenant) ID.                                                             |
| Timeout (`timeout`)                          | No       | Integer | 30      | Seconds to wait for API responses.                                                 |
| Fetch Users Licenses (`fetch_user_licenses`) | No       | Boolean | False   | Fetch the licenses assigned to each user.                                          |
| Fetch Admin Roles (`fetch_admin_roles`)      | No       | Boolean | False   | Fetch the directory (admin) roles of each user and attach them to the user record. |

## Troubleshooting

| Error message | Cause | Fix                                    |
| ------------- | ----- | -------------------------------------- |
| Not verified  |       | No adapter-specific error text in code |

## Change history

{% hint style="info" %}
Available starting from version 5.5.0.
{% endhint %}
