gpt4 book ai didi

authorization - 将 Office365 App "Read mail in All mailboxes"权限限制为特定邮箱

转载 作者:行者123 更新时间:2023-12-04 06:25:00 26 4
gpt4 key购买 nike

我正在尝试通过 MVC Web 应用程序中的 Office365 应用程序下载电子邮件。我正在努力在 Azure 事件目录上配置应用程序权限。权限说:“读取所有邮箱中的邮件”但是我想选择它可以访问/读取的邮箱。

有谁知道如何在 AAD 中设置权限更具体?谢谢你的帮助。

string authority = "https://login.microsoftonline.com/" + SettingsHelper.TenantId + "/oauth2/token";

var credential = new ClientCredential(SettingsHelper.ClientId, SettingsHelper.ClientSecret);
AuthenticationContext authContext = new AuthenticationContext(authority);
var authResult = await authContext.AcquireTokenAsync("https://graph.microsoft.com", credential);
var graphserviceClient = new GraphServiceClient(
new DelegateAuthenticationProvider(
(requestMessage) =>
{
requestMessage.Headers.Authorization = new AuthenticationHeaderValue("bearer", authResult.AccessToken);

return Task.FromResult(0);
}));

//This is Ok. I want to read this.
var allowedEmails = await graphserviceClient.Users["xxx@mydom.com"].Messages.Request().GetAsync();

//This is forbidden. I want to restrict this on AAD level.
var dissabledEmails = await graphserviceClient.Users["yyy@mydom.com"].Messages.Request().GetAsync();

enter image description here

enter image description here

最佳答案

使用 的应用程序客户凭证 身份验证流程不支持限制应用程序读取特定电子邮件。

但是你介意分享你正在工作的场景吗? 客户凭证 flow 用于自信的应用程序,这意味着该应用程序在安全的环境中运行。没有恶意用户可以获得 token 来访问您不想发布的信息。所以你可以限制你自己的应用程序中的资源。希望它有帮助。

关于authorization - 将 Office365 App "Read mail in All mailboxes"权限限制为特定邮箱,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38397981/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com