.NET MAUI Multi-platform App Sign-in user
This sample demonstrates a Windows desktop and Android mobile .NET MAUI Multi-platform App that sign-in users by using the Microsoft.Identity.Client.

đ This sample application backs one or more technical articles on docs.microsoft.com.
Prerequisites
- A Microsoft Entra tenant. You can open an Azure account for free to get a Microsoft Entra instance.
- .NET 6.0 SDK
- .NET MAUI
- Install apps from any source enabled in Windows' developer settings
- Device Emulators are configured
Setup
1. Register the web API application in your Microsoft Entra ID
First, complete the steps in Register an application with the Microsoft identity platform to register the sample app.
Use the following settings for your app registration:
| App registration setting |
Value for this sample app | Notes |
|---|---|---|
| Name | active-directory-dotnet-xplat-maui |
Suggested value for this sample. You can change the app name at any time. |
| Supported account types | Accounts in this organizational directory only (Single tenant) | Required for this sample. Support for the Single tenant. |
| Platform type | Mobile and desktop applications |
Required value for this sample. Enables the required and optional settings for the app type. |
| Redirect URI | https://login.microsoftonline.com/common/oauth2/nativeclient |
Required value for this sample. You can change that later in your own implementation. |
âšī¸ Bold text in the table matches (or is similar to) a UI element in the Microsoft Entra admin center, while
code formattingindicates a value you enter into a text box or select in the Microsoft Entra admin center.
2. Configure the MAUI app
Open the sign-in-xplat/MainPage.xaml.cs in your code editor.
private const string ClientId = "APPLICATION_(CLIENT)_ID"; private const string Tenant = "TENANT_ID";Open the sign-in-xplat/Platforms/Android/AndroidManifest.xml in your code editor and replace the
APPLICATION_(CLIENT)_IDplaceholder with your Application (Client) Id.<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round"> <activity android:name="microsoft.identity.client.BrowserTabActivity" android:exported="true"> <intent-filter> ... <data android:scheme="msalAPPLICATION_(CLIENT)_ID" android:host="auth" /> </intent-filter> </activity> </application>
Run the application
1. Run the .NET MAUI App
Android
- Select target Android emulator and then press
F5.
Windows
- Select Windows Machine and then press
F5.
2. Signin into the app
- Once the app is running you can sign-in with your user credentials.

About the code
This app uses the .NET MAUI Multi-platform App UI to provide a cross-platform experience in which the Microsoft Identity Client library is used to sign the user in and out of the application.
When a signed-out user clicks the sign in button, the app offers a native Microsoft Entra sign-in experience. After signing in, and if they've not previously done so, the user is asked to consent to the app's request for permission to access their data.
While signing in, a new token is acquired and passed in an Authorization header as Bearer for a subsequent call to Microsoft Graph. When a signed-out user the account is removed from the client cleaning up the user's retrieved information.
This cross-platform solution makes use of conditional compilation so that code is targeted to specific platforms when required.
Reporting problems
Sample app not working?
If you can't get the sample working, you've checked Stack Overflow, and you've already searched the issues in this sample's repository, open an issue report the problem.
- Search the GitHub issues in the repository - your problem might already have been reported or have an answer.
- Nothing similar? Open an issue that clearly explains the problem you're having running the sample app.
All other issues
â ī¸ WARNING: Any issue not limited to running this or another sample app will be closed without being addressed.
For all other requests, see Support and help options for developers | Microsoft identity platform.
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.