You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MS Teams自定义Bot出现Bad Gateway(502)及Error Code 911认证失败问题

MS Teams自定义应用Bot功能出现502 Bad Gateway及Error Code 911认证失败问题

在开发的MS Teams自定义应用中,使用Bot SDK的Adaptive Cards、搜索、Message Extensions等功能时,触发**Bad Gateway(502)**错误,同时返回Error Code 911,错误信息提示认证失败。

错误响应详情

// 20250212172704
// https://teams.microsoft.com/api/chatsvc/in/v1/agents/28:0bc21a2c-b9c1-4bd5-9989-0c5aaf324d64/invoke

{
  "errorCode": 911,
  "message": "Authentication failed.",
  "standardizedError": {
    "errorCode": 911,
    "errorSubCode": 1,
    "errorDescription": "Authentication failed."
  }
}

已排查情况

  • 核对所有配置字段,确认Bot拥有足够权限
  • 后端代码逻辑无明显问题
  • 已实现任务模块,但错误仍未解决

Bot后端代码

import { TeamsActivityHandler, CardFactory } from 'botbuilder';
import axios from 'axios';
import dotenv from 'dotenv';

dotenv.config();


export class TeamsMessagingExtensionsActionBot extends TeamsActivityHandler {
    constructor() {
        super();
        

        this.onInvokeActivity = async (context) => {
            const commandId = context.activity.value.commandId;
            console.log(`📌 Command ID received: ${commandId}`);
        
            let response;
            switch (commandId) {
                case "Create-Issue":
                case "create_Issue":
                    response = {
                        type: 'invokeResponse',
                        value: {
                            status: 200,
                            body: {
                                task: {
                                    type: 'continue',
                                    value: {
                                        url: "https://localhost:53000/#/dev-tab",
                                        title: "Create Jira Issue",
                                        height: "medium",
                                        width: "medium",
                                    }
                                }
                            }
                        }
                    };
                    break;
                case "Update-Issue":
                case "update_Issue":
                    response = {
                        type: 'invokeResponse',
                        value: {
                            status: 200,
                            body: {
                                task: {
                                    type: 'continue',
                                    value: {
                                        url: "https://localhost:53000/#/update-issue",
                                        title: "Update Jira Issue",
                                        height: "medium",
                                        width: "medium",
                                    }
                                }
                            }
                        }
                    };
                    break;
                case "Get-Issues":
                case "get_Issues":
                    response = {
                        type: 'invokeResponse',
                        value: {
                            status: 200,
                            body: {
                                task: {
                                    type: 'continue',
                                    value: {
                                        url: "https://localhost:53000/#/get-issue",
                                        title: "Get a Jira Issue",
                                        height: "medium",
                                        width: "medium",
                                    }
                                }
                            }
                        }
                    };
                    break;
                default:
                    response = {
                        type: 'invokeResponse',
                        value: {
                            status: 400,
                            body: {
                                task: {
                                    type: 'continue',
                                    value: {
                                        card: CardFactory.adaptiveCard({
                                            type: 'AdaptiveCard',
                                            body: [{ type: 'TextBlock', text: "Unknown action", weight: 'Bolder', size: 'Medium' }],
                                            $schema: 'http://adaptivecards.io/schemas/adaptive-card.json',
                                            version: '1.2'
                                        }),
                                        title: "Error",
                                        height: "medium"
                                    }
                                }
                            }
                        }
                    };
            }
        
            await context.sendActivity(response);
        };
        

        this.onMessage = async (context, next) => {
            const action = context.activity.value?.action;

            if (action === "create_issue") {
                const { issueTitle, issueDescription, priority } = context.activity.value;
                const response = await createJiraIssue(issueTitle, issueDescription, priority);
                await context.sendActivity(response);
            } 
            else if (action === "update_issue") {
                const { issueId, newDescription, status } = context.activity.value;
                const response = await updateJiraIssue(issueId, newDescription, status);
                await context.sendActivity(response);
            } 
            else if (action === "get_issues") {
                const { projectId } = context.activity.value;
                const response = await fetchJiraIssues(projectId);
                await context.sendActivity(response);
            }

            await next();
        };


        

    }


}

请求协助排查该认证失败错误的具体原因及修复方案。


内容的提问来源于stack exchange,提问作者Saransh Bhole

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 11:44:53