Microsoft Teams uses OAuth 2.0 client credentials via the Microsoft Graph API. You will need to register an Azure application, generate a client secret, and grant the required Application permissions with admin consent.

## 1. Register an Azure Application

In the [Azure portal](https://portal.azure.com), search for **App registrations** and select it. Click **+ New registration** -> enter a name -> select the appropriate supported account types -> leave **Redirect URI** blank -> click **Register**.

On the **Overview** page, copy the **Application (client) ID** and **Directory (tenant) ID** to a safe location.

## 2. Create a Client Secret

Navigate to **Manage** -> **Certificates & secrets** -> **+ New client secret**. Enter a description, choose an expiration period, and click **Add**.

Copy the secret **Value** immediately — it will not be shown again.

## 3. Add API Permissions

In the app registration, navigate to **Manage** -> **API permissions** -> **+ Add a permission** -> **Microsoft Graph** -> **Application permissions**. Add each of the following:

| Permission | Purpose |
|  --- | --- |
| `Channel.ReadBasic.All` | List channels within a team. |
| `ChannelMember.Read.All` | List members of a channel. |
| `ChannelMessage.Read.All` | Read messages posted in team channels. |
| `Chat.Read.All` | Read messages in 1:1 and group chats. |
| `User.Read.All` | List users in the tenant and resolve message authors. |


All permissions must be **Application** type, not **Delegated**.

Once added, click **Grant admin consent for [your tenant]** and confirm. This requires a Global Administrator or Privileged Role Administrator and is a one-time action.

## 4. (Optional) Find Your Team ID

The Team ID is required only if you want to query channel messages. If you are only querying user-scoped chats (DMs and group chats), skip this step.

1. In Microsoft Teams (web or desktop), locate the team you want to integrate.
2. Click the three-dot menu (`...`) next to the team name.
3. Select **Copy link to team**.
4. The copied URL looks similar to:
`https://teams.cloud.microsoft/l/team/19%3AkH2nP9rM4tQ6sW8vY1zXjL3aFcDuE5bN7%40thread.tacv2/conversations?groupId=b27d4e91-3a06-4f8c-9d12-7e5fa4ce8b03&tenantId=c3e7a209-8b45-4d16-a0f1-5c89d2b7e64a`
5. The Team ID is the value of the `groupId` query parameter — in the example above, `b27d4e91-3a06-4f8c-9d12-7e5fa4ce8b03`.


## 5. Configure the Integration

**Tenant ID**: The **Directory (tenant) ID** from step 1.

**Client ID**: The **Application (client) ID** from step 1.

**Client Secret**: The secret **Value** from step 2.

**Team ID** *(optional)*: The team's `groupId` from step 4. Required only for querying team channels.