diff --git a/apps/sim/blocks/blocks/microsoft_teams.ts b/apps/sim/blocks/blocks/microsoft_teams.ts index 45d005a2d2..a9e326624e 100644 --- a/apps/sim/blocks/blocks/microsoft_teams.ts +++ b/apps/sim/blocks/blocks/microsoft_teams.ts @@ -47,6 +47,7 @@ export const MicrosoftTeamsBlock: BlockConfig = { 'Channel.ReadBasic.All', 'ChannelMessage.Send', 'ChannelMessage.Read.All', + 'ChannelMember.Read.All', 'Group.Read.All', 'Group.ReadWrite.All', 'Team.ReadBasic.All', diff --git a/apps/sim/lib/auth.ts b/apps/sim/lib/auth.ts index 94f085a99e..cb00ea4307 100644 --- a/apps/sim/lib/auth.ts +++ b/apps/sim/lib/auth.ts @@ -512,6 +512,7 @@ export const auth = betterAuth({ 'Channel.ReadBasic.All', 'ChannelMessage.Send', 'ChannelMessage.Read.All', + 'ChannelMember.Read.All', 'Group.Read.All', 'Group.ReadWrite.All', 'Team.ReadBasic.All', diff --git a/apps/sim/lib/oauth/oauth.ts b/apps/sim/lib/oauth/oauth.ts index b7fa4240a4..5658509c59 100644 --- a/apps/sim/lib/oauth/oauth.ts +++ b/apps/sim/lib/oauth/oauth.ts @@ -239,6 +239,7 @@ export const OAUTH_PROVIDERS: Record = { 'Channel.ReadBasic.All', 'ChannelMessage.Send', 'ChannelMessage.Read.All', + 'ChannelMember.Read.All', 'Group.Read.All', 'Group.ReadWrite.All', 'Team.ReadBasic.All', diff --git a/apps/sim/tools/microsoft_teams/utils.ts b/apps/sim/tools/microsoft_teams/utils.ts index 1045889d8f..0f85153e49 100644 --- a/apps/sim/tools/microsoft_teams/utils.ts +++ b/apps/sim/tools/microsoft_teams/utils.ts @@ -180,10 +180,8 @@ async function fetchChannelMembers( channelId: string, accessToken: string ): Promise { - // Channel members endpoint requires ChannelMember.Read.All which may not be available - // Instead, fetch team members which works with the standard Teams permissions const response = await fetch( - `https://graph.microsoft.com/v1.0/teams/${encodeURIComponent(teamId)}/members`, + `https://graph.microsoft.com/v1.0/teams/${encodeURIComponent(teamId)}/channels/${encodeURIComponent(channelId)}/members`, { headers: { Authorization: `Bearer ${accessToken}`, @@ -193,7 +191,7 @@ async function fetchChannelMembers( ) if (!response.ok) { - logger.error('Failed to fetch team members:', { + logger.error('Failed to fetch channel members:', { status: response.status, statusText: response.statusText, }) @@ -207,7 +205,7 @@ async function fetchChannelMembers( userIdentityType: member.userIdentityType, })) - logger.info('Fetched team members for channel:', { + logger.info('Fetched channel members:', { count: members.length, members: members.map((m: TeamMember) => ({ displayName: m.displayName,