I have been recently tasked to query calendar detail using API from Office 365 but not to expose any private meeting details. For this situation I thought to make use of Outlook Rest API 2.0.
I will explain step by steps, how to create an app, which will only query calendar invite in the context of logged in user.
Prerequisites :
- Register an App in Office 365.
- Configure permission for ‘Office 365 Exchange Online’ and only select these 2 under ‘Delegate Permissions‘
- Read user and shared calendars.
- Read user calendars
- Configure permission for ‘Office 365 Exchange Online’ and only select these 2 under ‘Delegate Permissions‘
- Must have a regular user mailbox to query other user’s calendar detail.
- Use PostMan or any other such tools to query and then you can automate the process using powershell as well.
Validate Permission:
You should use Outlook REST API 2.0 to fetch details and here are steps to query in postman.
- Get New Access Token
- Token Name – Token Name
- Grant Type – Authorization Code
- Callback URL – https://localhost
- Auth URL – https://login.windows.net/common/oauth2/authorize?resource=https%3A%2F%2Fgraph.microsoft.com
- Access Token URL – https://login.windows.net/common/oauth2/token
- Client ID – <this is application id>
- Client Secret – <will be shared over slack>
- Scope – leave it blank
- State – State
- Client Authentication – Send as Basic Auth header
Click on ‘Request Token’ and use your Office 365 credentials, once prompted click allow to have access on calendar
- If successful, you will be presented to ‘use token’ option.
- Now you can put these details in GET Section to retrieve data through GRAPH API, you can use many more combination using Outlook Rest API 2.0
Retrieve Calendar Details
Since you were able to retrieve token, now you can use such urls to post query to office 365 to retrieve calendar details:
Thank you for reading !