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

Teams机器人认证时GetSignInResource接口频繁返回404求助

Teams机器人OAuth认证接口间歇性404问题求助

开发Teams机器人时,需通过OAuth认证调用Microsoft Graph API,但生成OAuth卡片依赖的https://api.botframework.com/api/botsignin/GetSignInResource接口频繁间歇性失败,直接中断认证流程。

问题现象

接口间歇性返回HTTP 404错误,错误响应内容为:

{"error": {"code": "ServiceError","message": "Bot does not exist"}}

偶尔能正常调用,成功时可生成OAuth卡片并完成令牌获取,但多数时候失败。状态无规律,有时等待数天会短暂恢复,随后再次失效。

实现方式

未直接使用Microsoft.Bot.Builder.Dialogs.OAuthPrompt组件,而是调用其底层SendOAuthCardAsync方法,核心代码如下:

this.ssoOptions = new OAuthPromptSettings
{
    ConnectionName = this.AzureConnectionName,
    Text = "Autoriser l'accès à vos données ?",
    Title = "Demande d'autorisation",
    Timeout = (int)MaxDelayToAuthenticate.TotalMilliseconds, //  TimeSpan.FromMinutes(5D)
    EndOnInvalidMessage = true,
};

protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turn, CancellationToken cancel)
{
    // more code here...

    if (startAuthentication)
    {
        DomainError error = null;
        var prompt = Activity.CreateMessageActivity();
        try
        {
            this.Logger.LogTrace($"RelaySemanticResponse: about to generate+send OAuth card with ConnectionName " + this.ssoOptions.ConnectionName);
            await OAuthPrompt.SendOAuthCardAsync(this.ssoOptions, turn, prompt, cancel);
            this.Logger.LogInformation($"RelaySemanticResponse: generate+send OAuth card with ConnectionName " + this.ssoOptions.ConnectionName + " DONE");
        }
        catch (HttpOperationException ex)
        {
            this.Logger.LogError($"RelaySemanticResponse: failed to generate+send OAuth card, HTTP error: " + ex.Message);
            error = new DomainError("ExternalError", ex.ToString(), null);
        }

        if (error != null) {
            // handle error
        }
    }

    // more code here...
}

已排查动作

  • 对比成功与失败请求的state参数,未发现结构差异
  • 在Teams应用清单中添加login.microsoftonline.com域名,问题未解决
  • 已在Bot Framework SDK相关仓库提交Issue

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.21 12:52:28