Microsoft graph api Azure AD应用程序注册-Exchange API-读取日历

Microsoft graph api Azure AD应用程序注册-Exchange API-读取日历,microsoft-graph-api,outlook-restapi,Microsoft Graph Api,Outlook Restapi,我在Azure AD应用程序中授予了以下权限: 应用程序: 授权: Read user and shared calendars Read and write user and shared calendars Read and write user calendars Read user calendars Read and write user and shared calendars Read user and shared calendars 我正在成功生成访问令牌,如下所示: co

我在Azure AD应用程序中授予了以下权限:

应用程序:

授权:

Read user and shared calendars
Read and write user and shared calendars
Read and write user calendars
Read user calendars
Read and write user and shared calendars
Read user and shared calendars

我正在成功生成访问令牌,如下所示:

const string clientId=“我的客户端id”;
const string clientSecret=“我的秘密”//C
var tenant=“mytenant.onmicrosoft.com”;
var authContext=新的AuthenticationContext($”https://login.windows.net/{tenant}/oauth2/token”);
var-credentials=新的ClientCredential(clientId,clientSecret);
AuthenticationResult authResult=等待authContext.AcquireTokenAsync(“https://graph.microsoft.com/“、全权证书);
使用该访问令牌,我试图向
/CalendarView
发出一个基本请求,传递承载令牌头:

https://outlook.office.com/api/v2.0/users/my@email.com/calendarview?startDateTime=2017-11-12&endDateTime=2017-11-13

但是,我一直收到
拒绝访问的消息。是否需要设置其他权限?我是否调用了正确的终结点?

您没有包含错误响应的主体,但我猜您遇到了这个问题,因为Exchange不会接受使用共享密钥生成的令牌。相反,您需要使用基于证书的断言来请求令牌。Azure将此记录为“第二种情况:使用证书访问令牌请求”。

我实际上能够理解这一点。我没有使用Exchange API,而是在Graph API中应用了权限

点击以下端点:

https://graph.microsoft.com/v1.0/users/{email}/calendarview?startDateTime={startDate}&endDateTime={endDate}

使用哪种API之间的区别不是很清楚。。。但我现在正在前进。

很高兴你解决了这个问题。问题是您混合了许多API:
Azure AD Graph
Microsoft Graph
Office 365 REST
Exchange Web Services
是具有不同权限和模式的不同API。通常,您希望坚持使用Microsoft Graph端点(
Graph.Microsoft.com
)。感谢您的反馈!
https://graph.microsoft.com/v1.0/users/{email}/calendarview?startDateTime={startDate}&endDateTime={endDate}