AskYous
AskYous

Reputation: 4750

OAuth Card in MS Teams?

I built my bot using Direct Line and authentication works there. But when I deployed my bot to MS Teams, pressing the sign in button does nothing at all. I used the following code:

AddDialog(new OAuthPrompt(
    nameof(OAuthPrompt),
    new OAuthPromptSettings
    {
        ConnectionName = ConnectionName,
        Text = "👋 Welcome! Please Sign In.",
        Title = "Sign In",
        Timeout = 300000, // User has 5 minutes to login (1000 * 60 * 5),
    })
);

I tried looking up documentation, but it seems they're using a different framework, or the v3 bot framework. How can I make OAuth work in web and ms teams?

I'm using Bot Framework v4.

Upvotes: 1

Views: 2454

Answers (2)

David
David

Reputation: 31

Some weeks ago, we faced the same problem.

Luckily, a few weeks ago, Microsoft uploaded a sample: https://github.com/microsoft/BotBuilder-Samples/tree/master/samples/javascript_nodejs/46.teams-auth

The key here is to use TeamsActivityHandler (found inside teamsActivityHandler.js file) instead of ActivityHandler when extending your bot.

Hope it helps!

Upvotes: 1

Mick
Mick

Reputation: 3024

How are you testing the Teams app? Did you side-load it into your Teams environment? When you are using Azure Bot Service for Authentication in Teams, you need to whitelist the domain in your Bot Manifest. This requirement applies to bots built with the v3 and v4 SDK.

You could use App Studio to add token.botframework.com to the validDomains section of the manifest file. (or you can build the manifest file manually)

Upvotes: 6

Related Questions