简体   繁体   English

通过Office 365 REST API访问共享日历(例如会议室)

[英]Access a shared calendar (such as a meeting room via Office 365 REST API)

I'm using the Office 365 REST api to access my account's calendars. 我正在使用Office 365 REST API访问我帐户的日历。 I'd like to access all the calendars my account has access to, in particular the meeting rooms calendars appearing in the "Other calendars" section in my Office 365 interface. 我想访问我的帐户有权访问的所有日历,特别是我的Office 365界面中“其他日历”部分中显示的会议室日历。

For now, if I query the " https://outlook.office365.com/api/v1.0/me/calendars " endpoint, I only got the calendars I own, not the meeting rooms calendars. 现在,如果我查询“ https://outlook.office365.com/api/v1.0/me/calendars ”端点,我只会收到我拥有的日历,而不是会议室日历。

Any clue on how to get them (via Office 365 REST API) ? 有关如何获取它们的任何线索(通过Office 365 REST API)?

The REST API doesn't support access to other user's calendars when logging in as a user. 以用户身份登录时,REST API不支持访问其他用户的日历。 You can use the client credentials model to grant the app access to all calendars in the organization and access them that way. 您可以使用客户端凭据模型授予应用程序对组织中所有日历的访问权限,并以这种方式访问​​它们。

I've been able to do what I believe you're asking about (using the office 365 API to get the events from calendars which have been shared with your outlook calendar) by using the following endpoint: 通过使用以下端点,我已经能够做我认为你所问的事情(使用office 365 API从已经与Outlook日历共享的日历中获取事件):

.../api/v2.0/Users('PRIMARY_USER_ID')/Calendars('SHARED_CALENDAR_ID')/Events

I'm not sure if this endpoint would get you access to ones you have partial access to, but you should be able to grab events/info from any calendar that has been directly shared with your outlook/office 365 account. 我不确定这个端点是否可以让您访问您可以部分访问的端点,但您应该能够从任何直接与Outlook / Office 365帐户共享的日历中获取事件/信息。

  • The PRIMARY_USER_ID (just what I'm calling it here) comes back to you as part of the response object when you first sign in with your outlook account and go through Microsoft's auth process. 当您首次使用Outlook帐户登录并通过Microsoft的身份验证过程时,PRIMARY_USER_ID(就在我在这里调用它)会作为响应对象的一部分返回给您。 This isn't the ID of the calendar you're trying to access, but the idea of the primary calendar (the one you can find at the api/v2.0/me endpoint) that the other calendars are shared with. 这不是您尝试访问的日历的ID,而是与其他日历共享的主日历(您可以在api/v2.0/me端点找到的日历)的概念。 All of the IDs I've seen have come back in the form of a bunch of letters and numbers separated by dashes. 我看到的所有ID都以一串字母和数字的形式返回,用短划线分隔。

  • The CALENDAR_ID is the ID of the shared calendar you're trying to get the events from. CALENDAR_ID是您尝试从中获取事件的共享日历的ID。 You can see these IDs for each of your shared calendars if you make a request to .../api/v2.0/me/calendars/ . 如果您向.../api/v2.0/me/calendars/发出请求,您可以查看每个共享日历的这些ID。 This will return each of the calendars that are shared with you, info about the owner, and the 'ID' of that calendar. 这将返回与您共享的每个日历,有关所有者的信息以及该日历的“ID”。

If you plug in those ids, and make a request to url above, you should be able to get calendar events back from the API. 如果你插入这些ID,并向上面的url发出请求,你应该能够从API获取日历事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM