Teams Messaging Extension 与操作命令、底层机器人和通过 Graph 访问之间的关系 API

Relationship between Teams Messaging Extension with action command, the underlying bot and access via Graph API

我想调用消息扩展(使用操作命令)并通过机器人访问图表 API 以获取频道的不同资源(例如,检索所有消息或获取对我的消息的回复)。 在 Microsoft 的示例中,作为先决条件,我必须执行“Bot 通道注册”,以便机器人通过 OAuth2 访问 Graph API。 我真的需要这个频道注册吗?或者有别的办法吗?

作为测试,我创建了一个 azure 免费试用版,我用它执行了“Bot 通道注册”,还可以在注册中保存 Graph Api 访问的 ID 和密码。有了这个我就成功了。现在 30 天的测试期已经结束,我很想知道它是否可以正常工作。

感谢您的帮助

更新: 那是我初始化图形的代码 api:

IConfidentialClientApplication app = ConfidentialClientApplicationBuilder.Create(AppId)
            .WithClientSecret(AppSecret)
            .WithAuthority(new Uri($"https://login.microsoftonline.com/{Tenant}"))
            .Build();
string[] scopes = new string[] { "https://graph.microsoft.com/.default" };
AuthenticationResult authenticationResult = await app.AcquireTokenForClient(scopes).ExecuteAsync();

var graphServiceClient = new GraphServiceClient(new DelegateAuthenticationProvider((requestMessage) =>
        {
            requestMessage
                .Headers
                .Authorization = new AuthenticationHeaderValue("Bearer", authenticationResult.AccessToken);
return Task.FromResult(0);
        }));

对于OAuth认证,你肯定需要用azure注册bot。