Office365 新的Microsoft Graph API-仅应用程序访问

Office365 新的Microsoft Graph API-仅应用程序访问,office365,office365-restapi,microsoft-graph-api,Office365,Office365 Restapi,Microsoft Graph Api,我想检查几个用户的日历。因此,我只需要应用程序访问(因为应用程序需要比登录用户更多的权限) 使用“旧”API时,可以按照以下说明进行操作: 对于新的Microsoft Graph API,这似乎不起作用。有没有办法让这一切顺利进行?我想将Microsoft Graph API用于我在应用程序中需要的所有Office 365 API函数 提前谢谢 (编辑:包括错误消息。) Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceExce

我想检查几个用户的日历。因此,我只需要应用程序访问(因为应用程序需要比登录用户更多的权限)

使用“旧”API时,可以按照以下说明进行操作:

对于新的Microsoft Graph API,这似乎不起作用。有没有办法让这一切顺利进行?我想将Microsoft Graph API用于我在应用程序中需要的所有Office 365 API函数

提前谢谢

(编辑:包括错误消息。)

Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException:AADSTS70002:验证凭据时出错。AADSTS50012:客户端断言包含无效签名。跟踪ID:718db531-d789-4b45-ae9d-c2e53f3786fd相关ID:6a157ae5-7dc3-4470-81c0-f410e14f9c04时间戳:2015-11-27 12:40:33Z-->System.Net.WebException:Der远程服务器hat einen Fehler zurückgeben:(401)Nicht autorisert。bei System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)

我给予了充分的授权和充分的申请授权。这是我得到的代币:

{"token_type":"Bearer","expires_in":"3599","scope":"Calendars.Read Calendars.ReadWrite Contacts.Read Contacts.ReadWrite Directory.AccessAsUser.All Directory.Read Directory.Read.All Directory.ReadWrite.All Directory.Write Files.Read Files.Read.All Files.Read.Selected Files.ReadWrite Files.ReadWrite.All Files.ReadWrite.AppFolder Files.ReadWrite.Selected full_access_as_user Group.Read.All Group.ReadWrite.All Mail.Read Mail.ReadWrite Mail.Send Notes.Create Notes.Read Notes.Read.All Notes.ReadWrite Notes.ReadWrite.All Notes.ReadWrite.CreatedByApp offline_access openid People.Read People.ReadWrite Sites.Read.All Tasks.ReadWrite User.Read User.Read.All User.ReadBasic.All User.ReadWrite User.ReadWrite.All user_impersonation","expires_on":"1448974661","not_before":"1448970761","resource":"https://graph.microsoft.com/","pwd_exp":"582983","pwd_url":"https://portal.microsoftonline.com/ChangePassword.aspx","access_token":"eyJ---------zQXg","refresh_token":"AAABAA--------pYSAA","id_token":"eyJ0eXAi-------4wIn0."}
除了我的日历,我没有阅读其他日历的权利

编辑: 我无法获取应用程序令牌…这是我的代码(应用程序令牌在我不使用新的graph api时工作过)

我通过AcquireTokenAsync尝试了不同的端点。 我总是收到错误信息:

{“AADSTS70002:验证凭据时出错。AADSTS50012:客户端断言包含无效签名。\r\n ACE ID:6fe2a6bd-77d3-47a8-83d4-e10aea69b88a\r\n相关ID:53071578-1c16-4c17-8f77-fc5821c18d4b\r\n签名:2015-12-02 08:05:25Z”


再次感谢

我也有类似的问题。我使用的是来自PnP站点的Create-SelfSignedCertificate.ps1。我改用Makecert,一切正常。基本上是按照理查兹这里的确切说明进行的

这些说明的哪一部分不起作用?您收到了什么错误消息,或者缺少了什么选项?您好,当我尝试将API与仅应用程序令牌一起使用时,我得到了以下响应:Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException:AADSTS70002:验证凭据时出错。AADSTS50012:客户端断言包含无效签名。跟踪ID:718db531-d789-4b45-ae9d-c2e53f3786fd相关ID:6a157ae5-7dc3-4470-81c0-f410e14f9c04时间戳:2015-11-27 12:40:33Z-->System.Net.WebException:Der远程服务器hat einen Fehler zurückgeben:(401)Nicht autorisert。bei System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)并且您确定在应用程序清单中设置了与用于签署客户端断言的私钥匹配的公共证书?我确定是的。因为它以前工作过…问题可能是我在使用clientlibraries的事实吗。。。。还有一个有趣的问题。我已授予用户所有权限(读取目录中的任何日历),但通过执行此REST命令“”,我得到403错误。我做错什么了吗?试着理解这个反应。那么您有一个已经使用各种客户端库(.Net?)调用SharePoint和Outlook的现有应用程序吗?或者您正在扩展应用程序以包括对Outlook的调用,为此,请查看Microsoft图表?
        string authority = appConfig["AuthorizationUri"].Replace("common", appConfig["ida:TenantId"]);
        AuthenticationContext authenticationContext = new AuthenticationContext(authority, false);
        string certfile = appConfig["o365_CertPath"];

        X509Certificate2 cert = new X509Certificate2(certfile, // password for the cert file containing private key 
                                                    appConfig["o365_CertPassword"],
                                                    X509KeyStorageFlags.MachineKeySet);

        ClientAssertionCertificate cac = new ClientAssertionCertificate(appConfig["ida:ClientId"], cert);

        AuthenticationResult authenticationResult = await authenticationContext.AcquireTokenAsync("https://outlook.office365.com", cac);
        this.currentAccessToken = authenticationResult.AccessToken;