【问题标题】:Graph Api Permission to Read EmailGraph Api 读取电子邮件的权限
【发布时间】:2020-10-19 00:18:40
【问题描述】:

我有以下 c# 代码。我正在尝试按照以下链接使用图形 api 阅读电子邮件以换取 365

Reading user emails using MS Graph API C#

 IConfidentialClientApplication cca = ConfidentialClientApplicationBuilder
                  .Create("myAppId")
                  .WithTenantId("myTenantId")
                  .WithClientSecret("myClientSecret")
                  .Build();
            ClientCredentialProvider ccp = new ClientCredentialProvider(cca);
            GraphServiceClient client = new GraphServiceClient(ccp);

  var users = await client.Users.Request()
                             .GetAsync();

我执行它并得到以下错误:

Microsoft.Graph.ServiceException:'代码:Authorization_RequestDenied 消息:权限不足,无法完成操作。

我已根据屏幕截图授予 mail.read 和 user.read 权限。

有什么建议吗?

谢谢。

【问题讨论】:

    标签: c# .net-core microsoft-graph-api azure-ad-graph-api


    【解决方案1】:

    正如您的代码所示,您使用client credential flow,它使用应用程序权限

    如果要使用var users = await client.Users.Request().GetAsync();列出用户,需要设置其中一项应用权限。

    【讨论】:

      猜你喜欢
      • 2013-03-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-23
      • 2011-04-06
      • 1970-01-01
      • 2017-09-29
      相关资源
      最近更新 更多