Get OAuth2 Access Tokens Microsoft 365 with Entra ID

I discuss the importance of having a OAuth2 access token for Microsoft 365 and explain how to obtain it using Microsoft Entra ID.

This page was originally published here ▶️ Get OAuth2 Access Tokens Microsoft 365 with Entra ID .

Before you even get started coding against the Office 365 APIs, you need to get an OAuth2 access token that is trusted by Office 365. Microsoft has set up Microsoft Entra ID as the trust and token issuer for Office 365 which is a great solution because you can use it to store your users or you can configure it to federate logins with your on-premises Active Directory or third party authentication system.

In order to obtain the access token you have to create an application in Microsoft Entra ID that has been given the necessary permissions to access resources in Office 365 like reading your calendar or writing to your contacts. Once you do that, when a user successfully authenticates against Microsoft Entra ID, before retrieving an access token, if they haven’t already done so Microsoft Entra ID will prompt them to grant consent to the application to do the things that the developer configured in the app such as reading your calendar and singing you in:

Microsoft Entra ID Authentication

Microsoft Entra ID Authentication

So how do you create this Microsoft Entra ID app? There are two ways at the present time. You can use the Add Connected Service dialog in Visual Studio 2013 to do this or you can create it manually form the Azure Management Portal .

At present the Azure Preview Portal does not give you the ability to create and manage Microsoft Entra ID apps so you have to use the full portal for now.

So let’s get started. You can read through the next two posts in order, or just jump to the one that interests you:

Andrew Connell
Developer & Chief Course Artisan, Voitanos LLC. | Microsoft MVP
Written by Andrew Connell

Andrew Connell is a web & cloud developer with a focus on Microsoft Azure & Microsoft 365. He’s received Microsoft’s MVP award every year since 2005 and has helped thousands of developers through the various courses he’s authored & taught. Andrew’s the founder of Voitanos and is dedicated to helping you be the best Microsoft 365 web & cloud developer. He lives with his wife & two kids in Florida.

Share & Comment