Acquiring an access token using a console application and call APIs with the Microsoft identity platform for developers

.NET Core

About this sample

A multi-target console application (.Net Core and .Net Framework) that acquires an access token for a protected API on Azure, using Microsoft identity platform for developers. There are steps demonstrating this scenario on Azure AD, Azure AD B2C and National Clouds.

On later steps, you will learn how to enrich the console application with a cross platform token cache and a custom Web UI (for .NET Core only).

Structure of the repository

This repository contains a progressive tutorial made of the following parts:

Sub folder Description
1. Calling Microsoft Graph This first part presents how to acquire an access token for Microsoft Graph, on Azure AD, Azure B2C and Azure National Clouds. Each scenario is separated on its correspondent sub-folder.
2. Cross platform token cache This step shows how to configure a cross platform token cache (Windows, Linux and MAC) leveraging Microsoft.Identity.Client.Extensions.Msal
3. Custom Web UI This step shows how to customize the UI on the authorization response for a console application.
4. Device Code flow This step shows how to authenticate using device code flow.


  • Install .NET Core for Windows by following the instructions at
  • An Internet connection
  • An Azure Active Directory (Azure AD) tenant. For more information on how to get an Azure AD tenant, see How to get an Azure AD tenant
  • A user account in your Azure AD tenant.


From your shell or command line:

git clone dotnet-desktop-tutorial
cd dotnet-desktop-tutorial

Given that the name of the sample is pretty long, that it has sub-folders and so are the name of the referenced NuGet packages, you might want to clone it in a folder close to the root of your hard drive, to avoid file size limitations on Windows.

Community Help and Support

Use Stack Overflow to get support from the community. Ask your questions on Stack Overflow first and browse existing issues to see if someone has asked your question before. Make sure that your questions or comments are tagged with [msal dotnet].

If you find a bug in the sample, please open an issue on GitHub Issues.

To provide a recommendation, visit the following User Voice page.


If you'd like to contribute to this sample, see CONTRIBUTING.MD.

This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact with any additional questions or comments.