OAuthPrompt 和 TeamsBotSsoPrompt 和 AdaptiveCard 不适用于 Teams Bot 中的 SSO

问题描述 投票:0回答:1

我尝试了 3 种在 Teams bot 中实现 SSO 的方法,但都不起作用。还有其他办法吗?这些有什么问题吗?

  1. 使用“OAuthPrompt”(botbuilder-dialogs)以及来自 https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-conversation-sso-quickstart/js 的源代码
  2. 使用 CardFactory 中的 (oAuthCard) AdaptiveCard 以及来自 https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-sso-adaptivecard
  3. 的源代码
  4. 使用“@microsoft/teamsfx”中的 TeamsBotSsoPrompt 以及来自 https://github.com/OfficeDev/teams-toolkit-samples/tree/v2.5.0/bot-sso
  5. 的源代码
  • 我检查了 Microsoft 的文档,并确保我的应用程序注册和配置设置正确。
  • token.botframework.com 和 graph.microsoft.com、*.ngrok-free.app、*.ngrok.io、“[my-domain].asse.devtunnels.ms”已添加到有效域列表中(清单文件)

(1)“OAuth提示”

  • “beginDialog(OAUTH_PROMPT)”后没有任何响应,最后请求超时。 OAuthPrompt 没有响应

  • 之前没有像往常一样显示“继续”按钮

  • 在“Azure Portal”的“Web Chat 测试”中运行良好

    OAuth提示无响应

        async promptStep(stepContext) {
            try {
                return await stepContext.beginDialog(OAUTH_PROMPT);
            } catch (err) {
                console.error(err);
            }
        }
this.addDialog(new OAuthPrompt(OAUTH_PROMPT, {
connectionName: process.env.connectionName,
text: 'Please Sign In',
title: 'Sign In',
timeout: 300000
}));
    async loginStep(stepContext) {
        // Get the token from the previous step. Note that we could also have gotten the
        // token directly from the prompt itself. There is an example of this in the next method.
        const tokenResponse = stepContext.result;
        if (!tokenResponse || !tokenResponse.token) {
            await stepContext.context.sendActivity('Login was not successful please try again.');
        } else {
            const client = new SimpleGraphClient(tokenResponse.token);
            const me = await client.getMe();
            const title = me ? me.jobTitle : 'UnKnown';
            await stepContext.context.sendActivity(`You're logged in as ${me.displayName} (${me.userPrincipalName}); your job title is: ${title}; your photo is: `);
            const photoBase64 = await client.GetPhotoAsync(tokenResponse.token);
            const card = CardFactory.thumbnailCard("", CardFactory.images([photoBase64]));
            await stepContext.context.sendActivity({attachments: [card]});
            return await stepContext.prompt(CONFIRM_PROMPT, 'Would you like to view your token?');
        }
        return await stepContext.endDialog();
    }

(2)“自适应卡”

  • 虽然返回了token,但无法通过Microsoft Graph API验证token,错误为“invalid Audience”

  • 没有弹出SSO登录窗口(与之前的OAuthPrompt Dialog相同)

  • 我已确保在“应用程序注册”的“API权限”中设置了Graph User.Read

  • 当我在环境变量中将机器人的“OAuth连接设置”中不存在的“xxxx”设置为“connectionName”时,仍然返回令牌

    AdaptiveCard 令牌无效

(3)“TeamsBotSso提示”

  • 与 OAuthPrompt 类似,如果“TeamsBotSsoPrompt”使用后没有 tokenResponse,因此向用户返回错误消息。 TeamsBotSsoPrompt 没有令牌响应 TeamsBotSso提示无响应
microsoft-teams microsoft-teams-js
1个回答
0
投票

我遇到了同样的问题,但这对某些用户有效,但对其他人无效,在这篇post中,他们建议使用不同的团队版本,但我正在使用网络应用程序,但不起作用。

© www.soinside.com 2019 - 2024. All rights reserved.