如何访问的Microsoft Office 365计划编程

问题描述 投票:2回答:1

我试图访问的Microsoft Office 365计划使用CSOM和Azure的应用程序。每当我尝试使用组ID我得到下面的错误访问策划师:

401 - 未经授权:访问被拒绝由于凭据无效。您没有权限查看使用您提供的凭据此目录或网页。

我已经给所需的权限Azure的图形API。应用 - 读取组所有,读取和写入组所有。委托 - Tasks.ReadWrite

下面是我使用的代码示例:

//Querying plans in current group await 
graphClient.Groups[groupId].Planner.Plans.Request().GetAsync();

是否有任何选项来实现这一目标。我需要访问的策划者和需要基于Office 365组创建桶和计划。

任何帮助深表感谢。提前致谢。

azure office365 sharepoint-online azure-ad-graph-api csom
1个回答
0
投票

你应该使用Microsoft图,而不是Azure的AD图形API。

https://docs.microsoft.com/en-us/graph/planner-concept-overview

另外,你需要与你的用户凭据访问计划进行身份验证。您可以更改GetAccessToken方法这种方式(例如,从链接博客)认证。

private async Task<string> GetAccessToken(string resourceId, string userName, string password)
{
    try
    {
        var authority = ConfigurationManager.AppSettings["ida:AuthorizationLoginUri"] + ConfigurationManager.AppSettings["ida:TenantId"];
        var authContext = new AuthenticationContext(authority);
        var credentials = new UserPasswordCredential(userName, password);
        var authResult = await authContext.AcquireTokenAsync(resourceId, ConfigurationManager.AppSettings["ida:ClientIdNativeClient"], credentials);

        // Get the result
        return authResult.AccessToken;
    }
    catch (Exception ex)
    {
       // TODO: handle the exception
       return;
    }

您还需要确保您的应用已在门户网站正确注册。请看看这是很有帮助的博客,说明如何让过去访问的策划者,当你描述的错误:https://karinebosch.wordpress.com/2017/12/18/microsoft-graph/

© www.soinside.com 2019 - 2024. All rights reserved.