Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

azure - How to access shared calendars from Office REST API?

This question has been asked several times and as per answers such as this it seems the API didn't support this then until recently as here which mentions that there are new scopes which allow accessing the shared calendars. But it still does not work.

I have tested this on two platforms: Azure and Microsoft Graph

  1. Azure Ad App

My application in Azure AD has all the required permissions: enter image description here

enter image description hereenter image description here

I make a call to Office API v.1.0 as:

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

It only gives me the calendar created by the current logged-in/authorising user.

Since this didn't work, I tried with the version 2 of the API but I got the following:

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.

So I tried with a Microsoft Graph Application

  1. Microsoft Graph App

My application here also contains all the required permissions.

enter image description here

I make call to the office API v2.0 as:

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

Again does not give me the shared calendars.

Any help is appreciated.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

A lot of stuff going on here :) However it seems the crux here is that you're expecting /Me/Calendars to include shared calendars. It does not. In order to access someone else's calendar that has been shared, you must access via the /Users/<id>/Calendars/ URL.

So for example if [email protected] logs in, and [email protected] has shared his calendar with him, then:

  • /Me/Calendars would ONLY show calendars in Bob's mailbox
  • /Users/[email protected]/Calendars would show calendars Bill has shared with Bob

Update: It seems there's a blocking issue on our side. We're working on it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...