MS Graph API Authentication | MS Teams | Bot framework

I am new to bot development. I am working on creating a MS Teams bot using bot framework. The bot will be installed in ‘Personal’ scope in Teams, and it doesn’t have any tab / messaging extension etc. Once installed, I want to get the list of all the members/ channels/ Notification updates (i.e. members added/deleted etc.). As per the different documentation, I can get the list using Graph API.

  1. List members of team - Microsoft Graph v1.0 | Microsoft Docs
  2. List members of a channel - Microsoft Graph v1.0 | Microsoft Docs

To achieve this, I need the token that will be passed in API. I am not sure how to implement that. I have followed the instructions mentioned in Add authentication to a bot in Bot Framework SDK - Bot Service | Microsoft Docs. There was a step to add ‘Add OAuth Connection Settings’ and there were multiple options in ‘Service Provider’. I selected ‘Azure Active Directory v2’. After doing that, it works and I can get the token, but it only works if during login, I user my azure directory credentials. I have a Microsoft account linked with my MS Teams which id different than the Azure account. A user in team can have a Microsoft account / work / office account so this needs to work for everyone so what would be the correct ‘Service Provider’ option that will work for all accounts?

I was thinking that the flow should be like:

  1. When clicks on ‘Add’ button to install the app in Teams
  2. Once added, bot will prompt for Graph API permission using OAuth.
  3. Once user gives the permission, I can use the token to call graph APIs.

I have also looked at the following tutorials:

  1. How to use Bot Framework Composer to build low-code Microsoft Teams bots (Part 1)
  2. Get user profile information in your Microsoft Teams bot with Microsoft Graph (Part 2) - YouTube

But after performing all the steps, when I try to login, it says – ‘This action can't be performed since the app does not exist or has been uninstalled.’.

I am not getting a clear approach on how to proceed with it.


As @Maxim has also suggested, if you want to have a bot that should run multitenant you need to put tenant Id as common in OAuth Setting in Azure bot. As the value suggest it isn't going to specific to single tenant and Redirect Uri should be set to https://token.botframework.com/.auth/web/redirect in app registration.

This is it, you don't need to add anything. This is also mention in the doc -- enter image description here

We have some sample around it as well that shows how to use Graph API with the bot -

https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/csharp_dotnetcore/24.bot-authentication-msgraph

You can setup this one and update the Graph calls to get member of team or channels.