botbuilder-dotnet: OAuthInput does not work from within MS Teams chat context

Version

4.10.0

Describe the bug

OauthInput for AdaptiveDialog is not working in MS Teams

To Reproduce

Steps to reproduce the behavior:

  1. Implement OAuthInput dialog to connect to a Generic Oauth provider using bot service
  2. Test locally, works
  3. Test remote using webchat, works
  4. Deploy in Teams using manifest
  5. Card shows to sign in, clicking the sign-in button doesn’t prompt any login / pop-up whatsoever, no message no nothing

Expected behavior

I’d expect the bot to behave the same as when using webchat, and thus display a prompt to login to the generic OAuth provider.

Additional context

Code snippet for the Oauth dialog creation, there’s not much more to it:

_oauthDialog = new OAuthInput()
{
    ConnectionName = configuration["ConnectionName"],
    Title = "Sign in",
    Text = "Please sign in using OAuth",
    Property = "user.authToken"
};

Maybe this bug belongs to MS Teams instead, I’m not sure and I have no way of telling it does I guess.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (6 by maintainers)

Most upvoted comments

@jsiegmund

Unfortunately, we have duplicate code in OAuthInput and OAuthPrompt, and it has diverged.

Those same lines in OAuthPrompt have been updated as follows: https://github.com/microsoft/botbuilder-dotnet/blob/main/libraries/Microsoft.Bot.Builder.Dialogs/Prompts/OAuthPrompt.cs#L401

f (turnContext.Activity.IsFromStreamingConnection() ||
                    (turnContext.TurnState.Get<ClaimsIdentity>(BotAdapter.BotIdentityKey) is ClaimsIdentity botIdentity && SkillValidation.IsSkillClaim(botIdentity.Claims)) ||
                    _settings.OAuthAppCredentials != null)
                {
                    if (turnContext.Activity.ChannelId == Channels.Emulator)
                    {
                        cardActionType = ActionTypes.OpenUrl;
                    }
                }
                else if (!ChannelRequiresSignInLink(turnContext.Activity.ChannelId))
                {
                    value = null;
                }

This same code should be in OAuthInput. I’ve raised this issue: https://github.com/microsoft/botbuilder-dotnet/issues/4467 to track.

We have the same Issue. When comparing the versions 4.9 and 4.10 of the OAuthInput.cs you will notice that in the method “ChannelSupportsOAuthCard” in version 4.10 the case statemant “case Channels.MSTeams” is no longer present. This leads to the fact that the Card is not generated as in 4.9, but is loaded from a resource. After we have reintroduced the mentioned case statemant, the MS-Teams login works again as expected. Probably something is wrong with the loaded card resource.