[英]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.