Unnie Ayilliath

Microsoft 365 | Azure | Identity Solutions

Quick guide to basics of Microsoft Graph API

What is Microsoft Graph?

Microsoft Graph is a REST API endpoint exposed via https://graph.microsoft.com. It provides a unified access endpoint to all the data, office graph intelligence and insights available inside your Office 365 tenant. If you are familiar with Facebook’s Graph API you can consider this as Office 365 version of that.


Wait, but Office 365 unified API does the same thing?

Oh yes, Office 365 unified API was just the preview name of this endpoint. Microsoft just renamed it to Microsoft Graph when they made it generally available.

What is so cool about this endpoint?

Before Microsoft Graph API was developed, all graph resources were exposed using individual dedicated service endpoints for each cloud services. Here to access each endpoint you need to create access token for the specific endpoint, which meant your application needs to create multiple access tokens if you are interacting with multiple cloud services. Now with Microsoft Graph , there is only one single unified endpoint from where you can access all the cloud services and  more importantly your application only need a single access token.


What type of applications can consume the Microsoft Graph API?

Since this is a REST API , you can access it from all kinds of  devices(mobile/web/desktop)  running on any OS (ios,android,windows,Mac OS etc ) and inside application  developed in any programming language like .Net, PHP, Java, Python etc. You can get all the code samples and SDKs for multiple platform here.

Okay, Microsoft Graph is cool, but should I be rewriting the applications already written using a individual endpoint?

There is no real need to rewrite your already existing application from using individual graph  to use Microsoft Graph. But if you do so please don’t forget to check whether Microsoft Graph API has all the features you are currently getting from the individual graph endpoint you are using.

What about the applications I am developing?

For all the applications you are currently developing or planning to develop, use Microsoft Graph API. Going forward all the new features will be made available only through the Microsoft Graph endpoint and also you will not need to play around with access tokens in your apps.

What is the authentication mechanism used ?

Microsoft Graph supports two authentication providers:

  1. Azure AD v2.0 : Using Azure AD v2.0 endpoint apps can authenticate users with both enterprise (Work or School ) accounts and personal Microsoft cloud identities.
  2. Azure AD : This works only for users with enterprise (Work or School ) accounts.

See this post on deciding between Azure Ad and Azure AD v2.0 endpoints.

To authenticate in your application and get access token you can use any of the below two authentication libraries:

  1. Active Directory Authentication Library (ADAL)
  2. Microsoft Authentication Library (MSAL): This is the successor of ADAL, but as of now 21 November 2016 , it is still in preview and not production ready. Going forward , MSAL should be favored over  ADAL unless for some exceptional cases such as ” you have to work with the original Azure AD and with ADFS, which aren’t supported by MSAL. If you need a token for a service that today accepts only tokens from the original Azure AD, such as the Azure ARM API, you’ll want to keep using ADAL.
Okay, so Microsoft Graph is REST endpoint and I don’t like to use REST in .Net projects?

Here is the cool thing, there is a Microsoft Graph Client Library which you can download from nuget. This library provides you with classes and methods which implements web requests to Microsoft Graph endpoints. So using this library you do not have to implement any web requests to access Graph resources.

What are the nuget packages I need to download to get started with my Microsoft Graph application?
  1. ADAL  or MSAL for authentication
  2. Microsoft Graph Client
What should  I do to start learning Microsoft Graph API?

You can visit  Microsoft Graph Home which contains all the relevant information about the API. It also has Graph explorer where you can run  Graph requests against a demo tenant or even better to sign in with your Microsoft account and run graph queries against your own office 365 tenant.

Graph Explorer

You can also see the code samples and SDKs for Graph API here.

Published by

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Website Powered by WordPress.com.

%d bloggers like this: