botbuilder-dotnet icon indicating copy to clipboard operation
botbuilder-dotnet copied to clipboard

GetConversationMembersAsync, CreateConversationAsync and SendToConversationAsync now returns Unauthorized

Open RicBruIAI opened this issue 1 year ago • 3 comments

Since the "MultiTenant" support has been deprecated, I must deploy bots as "SingleTenant". I had a logic which I must return the conversation members (GetConversationMembersAsync) and for a selected member I must send a private message (CreateConversationAsync and SendToConversationAsync).

But, starting from the GetConversationMembersAsync, it triggers this excepiton: "Operation returned an invalid status code 'Unauthorized'"

I have the following setup:

  • The bot has a linked app registration (should I add new permissions there?) and such app registration is multi-tenant (I CANNOT MODIFY THIS)
  • The bot is prepared like this:
var credentials = new MicrosoftAppCredentials(botConfiguration.BotAppId.ToString(), botConfiguration.BotAppSecret);
var client = new ConnectorClient(botConfiguration.BotServiceUrl, credentials);
var channelAccount = new ChannelAccount(botConfiguration.BotId, botConfiguration.BotName);
var users = await client.Conversations.GetConversationMembersAsync(channelId);

How can I fix this? This is very hurgent.

RicBruIAI avatar Aug 28 '25 11:08 RicBruIAI

Hello @RicBruIAI , Thank you for bringing this issue to our attention. We will check this with the internal team and let you know the update.

meantime can you check this thread-https://github.com/OfficeDev/Microsoft-Teams-Samples/issues/1747 Hope it is helpful!!!

sayali-MSFT avatar Aug 28 '25 12:08 sayali-MSFT

Hello @RicBruIAI , the Entra/AAD app is only for Auth between Bot and Teams Bots backend. Single Tenant for Azure bot creation and Multi-Tenant (Accounts in any organizational directory (Any Azure AD tenant – Multitenant) for AAD app is valid choice and expected to work. Could you please share in which flow the Unauthorized Error is coming from? Is it during Auth or while calling a Bot API?

sayali-MSFT avatar Aug 29 '25 08:08 sayali-MSFT

Hello @RicBruIAI , the Entra/AAD app is only for Auth between Bot and Teams Bots backend. Single Tenant for Azure bot creation and Multi-Tenant (Accounts in any organizational directory (Any Azure AD tenant – Multitenant) for AAD app is valid choice and expected to work. Could you please share in which flow the Unauthorized Error is coming from? Is it during Auth or while calling a Bot API?

Hi, the error is coming right when calling this: var users = await client.Conversations.GetConversationMembersAsync(channelId);

Could it be that I am missing to specify the tenant id somewhere during authentication of the client?

RicBruIAI avatar Aug 29 '25 08:08 RicBruIAI