简体   繁体   English

对于bot框架V4 Web聊天中的每个用户,AD身份验证令牌都不相同

[英]AD authentication token is not getting same for every user in bot framework V4 web chat

I am using Bot Framework V4, AD Authentication for our bot is working fine.But when ever i am trying to user new session it is taking the same Token by which it is logged previously. 我正在使用Bot Framework V4,我的机器人的AD身份验证工作正常。但是当我尝试使用新会话时,它采用的是先前记录的相同令牌。 So I am getting the same data in all the sessions. 所以我在所有会话中获得相同的数据。 I am using AuthenticationDialog provided by Enterprise Bot Template 我正在使用Enterprise Bot Template提供的AuthenticationDialog

Actual: I am getting logged in once and it is staying logged in all sessions(even in other machines) Expected: I expect every session should take me to the sign in card(OAurth card) 实际:我正在登录一次,并且它会在所有会话中保持登录状态(即使在其他计算机中)预期:我希望每次会话都能带我到登录卡(OAurth卡)

public class AuthenticationDialog : ComponentDialog
{
    private static AuthenticationResponses _responder = new AuthenticationResponses();

    public AuthenticationDialog(string connectionName)
        : base(nameof(AuthenticationDialog))
    {
        InitialDialogId = nameof(AuthenticationDialog);
        ConnectionName = connectionName;

        var authenticate = new WaterfallStep[]
        {
            PromptToLogin,
            FinishLoginDialog,
        };

        AddDialog(new WaterfallDialog(InitialDialogId, authenticate));
        AddDialog(new OAuthPrompt(DialogIds.LoginPrompt, new OAuthPromptSettings()
        {
            ConnectionName = ConnectionName,
            Title = AuthenticationStrings.TITLE,
            Text = AuthenticationStrings.PROMPT,
        }));
    }

    private string ConnectionName { get; set; }

    private async Task<DialogTurnResult> PromptToLogin(WaterfallStepContext sc, CancellationToken cancellationToken)
    {
        return await sc.PromptAsync(AuthenticationResponses.ResponseIds.LoginPrompt, new PromptOptions());
    }

    private async Task<DialogTurnResult> FinishLoginDialog(WaterfallStepContext sc, CancellationToken cancellationToken)
    {
        var activity = sc.Context.Activity;
        if (sc.Result != null)
        {
            var tokenResponse = sc.Result as TokenResponse;

            if (tokenResponse?.Token != null)
            {
                var user = await GetProfile(sc.Context, tokenResponse);
                await _responder.ReplyWith(sc.Context, AuthenticationResponses.ResponseIds.SucceededMessage, new { name = user.DisplayName });
                return await sc.EndDialogAsync(tokenResponse);
            }
        }
        else
        {
            await _responder.ReplyWith(sc.Context, AuthenticationResponses.ResponseIds.FailedMessage);
        }

        return await sc.EndDialogAsync();
    }

    private async Task<User> GetProfile(ITurnContext context, TokenResponse tokenResponse)
    {
        var token = tokenResponse;
        var client = new GraphClient(token.Token);

        return await client.GetMe();
    }

    private class DialogIds
    {
        public const string LoginPrompt = "loginPrompt";
    }
}

This is a known issue in WebChat. 这是WebChat中的一个已知问题 When you use the same user id for every conversation, the conversation will reference the same data stores. 当您为每个对话使用相同的用户ID时,对话将引用相同的数据存储。 To resolve this issue, I would recommend generating random user ids for each conversation. 要解决此问题,我建议为每个对话生成随机用户ID。

Hope this helps. 希望这可以帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在我的聊天机器人中添加 AD 身份验证 - MS 机器人框架 v4 - How to add AD authentication in my Chat bot - MS bot framework v4 Bot Framework v4身份验证令牌已缓存 - Bot framework v4 authentication token cached BOT 不会使用 web-chat v4 框架调用 PromptDialog.Choice 中定义的 choiceSelection 方法 - BOT does not calls choiceSelection method defined in PromptDialog.Choice using web-chat v4 framework Bot Framework v4 c# - 如何保存用户和聊天机器人之间的整个聊天对话 - Bot Framework v4 c# - How to save entire chat conversation between user and chatbot Bot Framework v4 Bot仿真器身份验证错误请求 - Bot Framework v4 Bot emulator authentication bad request 如何在 Bot Framework v4 中的某些对话后禁用聊天 - How to disable the chat after certain conversation in Bot Framework v4 如何在 Web 频道聊天机器人中显示自适应卡片中的取消按钮,该聊天机器人在 MS Bot 框架 SDK V4 中的 C# 中开发? - How to have cancel button in Adaptive cards to be displayed in Web Channel chat bot developed in MS Bot framework SDK V4 in C#? 在 angular 应用程序和 v4 Bot Framework Bot 之间发送聊天记录(C# +.Net Core Web 应用程序,Angular 8 前端) - Sending chat history between angular app and v4 Bot Framework Bot (C# + .Net Core Web Application, Angular 8 Frontend) Ms Bot 虚拟助手 bot 框架 V4 中的用户头像 - User Avatar in Ms Bot virtual Assistant bot framework V4 向Bot V4添加身份验证不会提示用户登录 - Add authentication to Bot V4 does not prompt for user login
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM