- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在关注 teams auth sample在这里可用。要使用带有 AADV2 连接的 oAuth Prompt 登录机器人,会收到 token ,但大约一小时后,机器人会再次提示“登录”,根据我的理解,机器人应该静默获取新 token ,而不是提示用户登录。
在示例中,它提到了 this但不确定这到底是什么意思。
由于用户已经登录,我们如何在不再次登录提示的情况下获取新 token ?
最佳答案
该机器人并非设计用于自动刷新 token 。这是开发人员检查 token 是否有效/未过期,如果有效,请请求一个新 token (重新提示登录)。您在第二个链接中引用的代码行展示了如何不在每一轮都将提示发送给用户(这对用户来说会变得非常乏味),而是在每一轮检查 token 是否有效。在 token 有效的那一小时,它返回有效 token 并且用户无论如何都不受影响。 token 过期后,因为这个检查,oauthprompt 卡被重新发送给用户重新登录。
如果用户在上一步的提示中选择"is",则以下方法将运行。然后获取该事件 (const result = stepContext.result
),并将其发送回 OAuthPrompt 以查看其上是否有有效 token 。 :
async displayTokenPhase1(stepContext) {
await stepContext.context.sendActivity('Thank you.');
const result = stepContext.result;
if (result) {
// Call the prompt again because we need the token. The reasons for this are:
// 1. If the user is already logged in we do not need to store the token locally in the bot and worry
// about refreshing it. We can always just call the prompt again to get the token.
// 2. We never know how long it will take a user to respond. By the time the
// user responds the token may have expired. The user would then be prompted to login again.
//
// There is no reason to store the token locally in the bot because we can always just call
// the OAuth prompt to get the token or get a new token if needed.
return await stepContext.beginDialog(OAUTH_PROMPT);
}
return await stepContext.endDialog();
}
OauthPrompt 的构造函数的一部分正在检查是否已经存在有效 token :
/**
* Creates a new OAuthPrompt instance.
* @param dialogId Unique ID of the dialog within its parent `DialogSet` or `ComponentDialog`.
* @param settings Settings used to configure the prompt.
* @param validator (Optional) validator that will be called each time the user responds to the prompt.
*/
constructor(dialogId: string, private settings: OAuthPromptSettings, private validator?: PromptValidator<TokenResponse>) {
super(dialogId);
}
public async beginDialog(dc: DialogContext, options?: PromptOptions): Promise<DialogTurnResult> {
// Ensure prompts have input hint set
const o: Partial<PromptOptions> = {...options};
if (o.prompt && typeof o.prompt === 'object' && typeof o.prompt.inputHint !== 'string') {
o.prompt.inputHint = InputHints.ExpectingInput;
}
if (o.retryPrompt && typeof o.retryPrompt === 'object' && typeof o.retryPrompt.inputHint !== 'string') {
o.retryPrompt.inputHint = InputHints.ExpectingInput;
}
// Initialize prompt state
const timeout: number = typeof this.settings.timeout === 'number' ? this.settings.timeout : 54000000;
const state: OAuthPromptState = dc.activeDialog.state as OAuthPromptState;
state.state = {};
state.options = o;
state.expires = new Date().getTime() + timeout;
// Attempt to get the users token
const output: TokenResponse = await this.getUserToken(dc.context);
if (output !== undefined) {
// Return token
return await dc.endDialog(output);
} else {
// Prompt user to login
await this.sendOAuthCardAsync(dc.context, state.options.prompt);
return Dialog.EndOfTurn;
}
}
评论对此不是很清楚。为了清楚起见,我重写了其中的一些内容,并将与同事联系以解决此问题。
// Call the prompt again because we need the token. The reasons for this are:
// 1. If the user is already logged in, we do not need to store the token locally in the bot. We can always just call the prompt again to get the token.
// 2. We never know how long it will take a user to respond. By the time the
// user responds the token may have expired. The user would then be prompted to login again.
// 3. If the token is expired, OAuthPrompt will send a new login card to the user to login, and get a new token
关于botframework - 团队机器人授权 : oAuth card prompts for login every hour with AADV2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62527519/
我正在学习使用 PowerShell 编写脚本,我发现这段代码可以帮助我完成一个项目 该示例来自 Is there a one-liner for using default values with
出于好奇,window.prompt 和 JavaScript 中的 prompt 之间有什么区别。 老师用的我考试题的答案之一 var yourName = window.prompt("Pleas
我正在使用 Phonegap 构建一个应用程序我正在使用 javascript 提示输入类别名称,效果很好 var newcat=prompt("ADD CATEGORY",""); 我想将其
我正在使用 Anaconda 学习 Python。早些时候我只有 Anaconda Prompt。但是最近通过 更新了 Anaconda 之后 conda update conda 我是来看Anaco
我有一个对话框,其中有多个提示(Prompts.text, Prompts.number, Prompts.Choice,提示.确认)。虽然 Prompts.choice 和 Prompts.conf
我有一个引用参数“Year_Parameter”的值提示,以及一个包含一列(数据项表达式)的列表,该列表以这种方式引用与值提示相同的参数: #prompt('Year_Parameter')# 值提示
我正在尝试从绘制 ZSH shell 提示的函数中将当前光标位置(当前行号和列)读入一个变量中。我的目标是在提示下方显示内容,仅当有足够多的空行不会导致额外滚动时。 在交互式 shell 中,我可以使
有什么(支持的)方法可以做到这一点吗? IIRC 当使用“比 X 更暗”的色调颜色时,它通常会在某个时刻自行切换为白色,但我们的方案似乎处于边缘。 最佳答案 在 iOS5 中可以实现: [[UINav
如果生成的列表对于打开的命令提示符窗口的高度来说太长(就像这个长分支列表),它就会卡在这里。它首先显示适合窗口的内容,然后显示 :,如果按 ↓,您将到达列表的末尾,并显示 (END) 如何摆脱这种情况
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a software
例如,我想删除 AppData/Roaming/MyFolder/myfile.txt 中的文件。 我使用命令提示符并输入:del %userprofile%/AppData/Roaming/MyFo
例如,我想删除 AppData/Roaming/MyFolder/myfile.txt 中的文件。 我使用命令提示符并输入:del %userprofile%/AppData/Roaming/MyFo
这个问题已经有答案了: Is there a destructor for Java? (24 个回答) 已关闭 8 年前。 我正在将一些 C++ 代码移植到 Java,这些代码使用非常常见的 C++
在android中我定义了一个布局如下: ... 但由于某些原因,当我启动相应的 Activity 时,微调器的 android:promp 文本未显示。为了完整起见
代码是这样的: for(var node=iterator.iterateNext(),origin_background=node.style.background;node;node=iterat
仅当用户在提示中单击取消 时,下面的代码才会运行alert('Please enter your name!');。如果用户未在提示框中输入任何内容并单击 Enter,我试图让代码也运行所述警报。但是
我想知道是否可以根据当前路径或pwd值更改PS1? 例如: cd /home/user/directory1 PS1=[\e[1;32m\u\e[m@\e[1;34m\h\e[m \e[1;33m\W
这是一个奇怪的问题,我无法通过 Google 找到好的答案(当然,我总是有可能会失败)。在我的 bash 提示符下,如果我给提示符的一部分涂上颜色,当我按“向上”键转到上一个命令时,在超过一定数量的字
有没有办法验证javascript中调用window.prompt()显示的提示框的输入textBox的文本? 我的意思是,如果输入文本框中写入的字符串包含数字或我定义的其他非法字符等,则在单击“确定
我正在努力使用 HTML 代码来验证外部 js 文件中 Javascript Prompt() 的输入。我了解调用 Javascript 函数进行验证,并且知道如何编写该函数,但是如何“监听”HTML
我是一名优秀的程序员,十分优秀!