Search code examples
c#botframeworkmicrosoft-teams

How to silently authenticate a multi-tenant Teams bot on behalf of a user?


How can I authenticate a multi-tenant bot silently on behalf of a user? I'm trying to replicate the behavior of the Microsoft Flow bot in Teams. This bot does not prompt the user to authenticate with an Oauth2 card, and it seamlessly retrieves my flows. How can I get the token of the current session from Teams to use it, for example, in a call to the Graph API? MS Bot Flow


Solution

  • Per the docs:

    Currently, silent authentication only works for tabs. It does not yet work when signing in from a bot.

    That being said, if you create a bot that has tabs, the user can click on the tab to silently authenticate. It's not ideal, but for now, that's all there is.

    The official Teams Sample Bot does this.

    Follow the linked sample and docs to accomplish this. The docs, especially, lay it out pretty well.