Connecting to Microsoft Services through Microsoft Graph API

This is to share the knowledge on how we can use the Microsoft Graph API to connect to Microsoft Services and do CRUD operations on it. In my Article here, I’m using the Microsoft TeamsOnline Meeting APIs and will explain from the Authentication, Authorization -> Creating Meetings and Retrieve the Microsoft Teams Online Meeting Information.

Here planned to cover the below sections:

  1. How Authentication and Authorization happens through Microsoft Graph API with Microsoft Services.
  2. Setting up a trial Microsoft Trial Business Account ( For our Testing purpose )
  3. Registering the Application in the Azure Portal
  4. Adding Permissions to the Microsoft Teams Online Meeting
  5. Testing the Microsoft Teams — Online Meeting API’s using Postman Client

The below diagram depicts how the Authentication and Authorization works while we are connecting to Microsoft Graph API.

Note: The version of the below diagram can be found here.

Follow this Microsoft Guide to setup a Microsoft Trial Business Account.

Once you successfully registered with the Microsoft Trial Account, you will get the access to the Microsoft 365 Admin Center and below screen will appear.

Then to go to the Azure Portal follow the below screens.

At this step we have the Client ID and Tenant ID.

To generate the Client Secret, Go to the below screens.

After that you can see the Secret in the above highlighted line, you need to take a copy of it as the second time the value will not be exposed.

That’s it now we have the Client ID, Client Secret and Tenant ID, also specified the Redirect URL, when testing through the Postman Client the Redirect URL is not important, but when we are dealing with any Application, we need to create a Service to accept requests on that specific Redirect URL ( Then all the business logic need to be executed from that Service ).

After selecting your specific Application, go to -> API Permissions TAB and follow the below screens.

After clicking the Add Permission-> Select the Microsoft Graph -> Application Permissions and follow the below screens.

Now we are done with the Application Permissions.

Step-1: First thing we need to invoke is the authorize API. To see what are endpoints, you can go to Azure Portal and under specific application -> click Endpoints.

You will get all the endpoints and highlighted are my required ones.

As the authorize API call, when invoking first time it will pop-up with the Microsoft Login page to get the user consent. Below is the sample authorize API endpoint call.

Once you execute in the browser you will get the consent page as below:

Then login using your Microsoft Account Credentials.

After a successful call you will get the below page.

Now we need to extract the code value from the URL and need to invoke the token API.

Sample response will be like below.

Now we can use access token and can invoke create online meeting API.

Sample Response

That’s it, Likewise you can call the other API’s as well.



Associate Architect — Enterprise Integration | WSO2 Certified Solution Architect |

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store