这个问题已被问过多次,答案如 this似乎 API 直到最近才支持此功能 here其中提到有允许访问共享日历的新范围。但它仍然不起作用。
我已在两个平台上对此进行了测试:Azure 和 Microsoft Graph
- Azure 广告应用
我调用 Office API v.1.0:
Authorise URL:
https://login.microsoftonline.com/common/oauth2/authorize?client_id=%1$s&redirect_uri=%2$s&response_type=code
Token URL:
https://login.microsoftonline.com/common/oauth2/token
Calendars URL:
https://outlook.office.com/api/v1.0/Me/Calendars
它只提供当前登录/授权用户创建的日历。
由于这不起作用,我尝试使用 API 的版本 2,但得到以下结果:
Additional technical information: Correlation ID: 7abf370a-d918-4514-bd74-cf5fc93fe3cf Timestamp: 2016-10-31 09:32:06Z AADSTS70001: Application 'f7571710-84e2-4444-8bfe-5eef92f4a46d' is not supported for this API version.
所以我尝试使用 Microsoft Graph 应用程序
- Microsoft Graph 应用
我的应用程序还包含所有必需的权限。
我调用 Office API v2.0 的方式为:
Authorize URL:
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=%1$s&redirect_uri=%2$s&response_type=code&scope=%3$s
Where scopes are:
private static $scopes = array( 'https://outlook.office.com/calendars.read', 'https://outlook.office.com/calendars.readwrite', 'https://outlook.office.com/calendars.read.shared', 'https://outlook.office.com/calendars.readwrite.shared', );
Token URL:
https://login.microsoftonline.com/common/oauth2/v2.0/token
Calendars URL:
https://outlook.office.com/api/v2.0/Me/Calendars
再次没有给我共享日历。
感谢任何帮助。
最佳答案
这里发生了很多事情:)然而,这里的关键似乎是你期待 /Me/Calendars
包括共享日历。它不是。为了访问其他人已共享的日历,您必须通过 /Users/<id>/Calendars/
访问网址。
例如,如果 [email protected]登录,然后[email protected]与他分享了他的日历,然后:
-
/Me/Calendars
只会显示 Bob 邮箱中的日历 -
/Users/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f3919a9f9fb3909c9d879c809cdd909c9e" rel="noreferrer noopener nofollow">[email protected]</a>/Calendars
将显示 Bill 与 Bob 共享的日历
更新:我们这边似乎存在阻塞问题。我们正在努力。
关于azure - 如何从 Office REST API 访问共享日历?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40381513/