MS-Graph 在管理员同意的情况下读取任务



我正在尝试为租户的用户读取规划器任务。因此,我为正在执行此操作的应用程序配置了"Tasks.Read","Tasks.Read.Shared","Groups.Read.All","Groups.ReadWrite.All"的管理员同意。 就像这里提到的: https://learn.microsoft.com/de-de/graph/api/planneruser-list-tasks?view=graph-rest-1.0&tabs=http 我决定我的代码来获得一个令牌,如下所示:https://briantjackett.com/2018/12/13/introduction-to-calling-microsoft-graph-from-a-c-net-core-application/我得到了一个令牌,它是有效的。(使用贝勒令牌检查工具检查。 我以为我可以从图形 API 访问任务,例如"/v1.0/users/{userId}/planner/tasks",但我得到了 HTTP 401。 谁能给我缺失的链接?多谢。

_appId = configuration.GetValue<string>("AppId");
_tenantId = configuration.GetValue<string>("TenantId");
_clientSecret = configuration.GetValue<string>("ClientSecret");
_clientApplication = ConfidentialClientApplicationBuilder
.Create(_appId)
.WithTenantId(_tenantId)
.WithClientSecret(_clientSecret)
.Build();
var graphClient = GraphClientFactory.Create(new DelegateAuthenticationProvider(Authenticate));
var result = await graphClient.GetAsync($"/v1.0/users/{userId}/planner/tasks")
public async Task<string> GetTokenAsync()
{
AuthenticationResult authResult = await _clientApplication.AcquireTokenForClient(_scopes)
.ExecuteAsync();
return authResult.AccessToken;
}
private async Task Authenticate(HttpRequestMessage request)
{
var token = await GetTokenAsync();
request.Headers.Authorization = new AuthenticationHeaderValue("bearer", token);
}

目前不允许其他用户执行读取任务。用户只能读取其分配的任务。或者,如果要从一组计划中收集分配,则可以读取特定计划中的任务,并从该数据中对用户进行排序。您可以在 Planner UserVoice 中提供有关此行为的反馈,并说明您尝试完成的任务。

此外,如果应用程序权限适用于你的方案,则现在支持应用程序权限。

/v1.0/users/{userId}/planner/tasks用于通过获取用户来获取任务,您将需要用户权限(User.Read.All(才能通过该调用获取任务。

(你真的需要Groups.ReadWrite.All吗?您是否正在对组进行更改?- 它不是你的原始描述(

最新更新