Accessing Office 365 / Microsoft Cloud Data On SharePoint Using Graph API - Part Two


In this article series, we are focusing on accessing the Office 365 and Microsoft cloud services data using Graph REST API calls. Here, in this article, let us see how to access the Office 365 Outlook calendar events with the help of Microsoft Graph API.

Microsoft Graph exposes Office 365 and other Microsoft cloud services data like Outlook mail, Outlook calendar, OneDrive, tasks, groups, SharePoint, etc. through single endpoint URL (

In my previous article, you have seen the basic introduction and app registration process for accessing the Microsoft Graph data.

The data can be extracted by the following flow.

  • Get access token for authentication.

  • Access the Microsoft services data over graph API.

Acquire Access Token

There are two ways to get an access token. Here, I am only focusing on single approach. In this approach, we will be getting the access token using authentication server URL (<>/oauth2/authorize) with GET method.

The parameters passed for getting the token are,

  • Client ID

  • Response type

  • Resource URL

  • Redirect URL

Fire the constructed URL in the browser using window.location script, and the page will be redirected to the redirect URL specified. In the response URL, the access token will be available. The response URL will be redirect URL specified for redirection.

  1. function requestToken() 

  2. {   

  3. var clientId    = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';  

  4. var replyUrl    = '';   

  5. var resource = "";  

  6. var authServer  = '';    

  7. var responseType = 'token';   

  8. var url = authServer +   

  9. "response_type=" + encodeURI(responseType)