如何在我的 API 中对 EWS 应用程序中的用户进行身份验证

问题描述

我正在开发一个 API,该 API 将与 Microsoft Graph(日历)链接,对于我想要存储其 OAuth 凭据的每个客户端。我需要我的 API 向客户端发送一些内容以进行身份​​验证,然后我验证并接收凭据。

我该怎么做?

在 azure 上注册应用程序后,我只找到了 2 个选项:

1 - 我执行打开我通过桌面进行身份验证的代码

        var pcaOptions = new PublicclientApplicationoptions
        {
            ClientId = "client_id",TenantId = "tenant_id"
        };

        var pca = PublicclientApplicationBuilder
            .CreateWithApplicationoptions(pcaOptions).Build();            

        // The permission scope required for EWS access
        var ewsScopes = new string[] { "https://outlook.office365.com/EWS.AccessAsUser.All" };

        // Make the interactive token request
        var authResult = await pca.AcquiretokenInteractive(ewsScopes).ExecuteAsync();

enter image description here

2 - 我使用 client_secret 执行代码

            var cca = ConfidentialClientApplicationBuilder
            .Create("client_id")
            .WithClientSecret("client_secret")
            .WithTenantId("tenantId")
            .Build();

        // The permission scope required for EWS access
        var ewsScopes2 = new string[] { "https://outlook.office365.com/.default" };

        //Make the token request
        var authResult2 = await cca.AcquiretokenForClient(ewsScopes2).ExecuteAsync();

第二个选项的问题在于客户端必须手动创建 client_secret。

我想做一些类似于 Cronofy 服务的事情,它可以在您的平台上同步我的日历:

enter image description here

立即打开 Outlook 页面对我进行身份验证。

我可以在我的 API 中做些什么吗? 或者我必须有一个像 cronofy 这样的前端才能运行。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)