/MSAL-Windows-Integrated-Auth-WPF

Sample showing how a windows Desktop .NET (WPF) application can get an access token using MSAL.NET and call the Microsoft Graph API or other APIs protected by Azure Active Directory v2

Primary LanguageC#MIT LicenseMIT

services platforms author level client service endpoint
active-directory
dotnet
jmprieur
200
.NET Framework 4.5 WPF
Microsoft Graph
AAD V2

Build Badge

this sample is for MSAL 2.x, if you are interested in the same code for MSAL 1.x, look at the releases tab

WPF application signing in users with Microsoft and calling the Microsoft Graph

Getting Started Library Docs Support

This simple sample demonstrates how to use the Microsoft Authentication Library (MSAL) for .NET to get an access token and call the Microsoft Graph (using OAuth 2.0 against the Azure AD v2.0 endpoint).

Topology

Steps to Run

You can get full explanation about this sample, and build it from scratch by going to Windows desktop .NET guided walkthrough.

This sample is pre-configured. If you just want to quickly run it just:

  1. Clone the code.
  git clone https://github.com/Azure-Samples/active-directory-dotnet-desktop-msgraph-v2.git
  1. Run the application from Visual Studio (Debug | Start without Debugging)

[Optional] Use your own application coordinates

If you want to use your own application coordinates, please follow these instructions:

  1. Register an Azure AD v2.0 (converged) app.

    • Navigate to the App Registration Portal.
    • Go to the the My Apps page, click Add an App, and name your app.
    • Set a platform by clicking Add Platform, select Native.
    • Copy to the clipboard your Application Id
  2. In the App.xaml.cs file, set your application/client id copied from the App Registration Portal.

    private static string ClientId = "[Application Id pasted from the application registration portal]"

  3. Run the application from Visual Studio (Debug | Start without Debugging)

Community Help and Support

We use Stack Overflow with the community to provide support. We highly recommend you 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 raise the issue on GitHub Issues.

If you find a bug in msal.Net, please raise the issue on MSAL.NET GitHub Issues.

To provide a recommendation, visit our User Voice page.

Contributing

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 opencode@microsoft.com with any additional questions or comments.

More information

For more information see MSAL.NET's conceptual documentation: