Migrate Android applications that use a broker from ADAL.NET to MSAL.NET
If you have a Xamarin Android app currently using the Azure Active Directory Authentication Library for .NET (ADAL.NET) and an authentication broker, it's time to migrate to the Microsoft Authentication Library for .NET (MSAL.NET).
Prerequisites
- A Xamarin Android app already integrated with a broker (Microsoft Authenticator or Intune Company Portal) and ADAL.NET that you need to migrate to MSAL.NET.
Step 1: Enable the broker
Current ADAL code: | MSAL counterpart: |
In ADAL.NET, broker support is enabled on a per-authentication context basis.
To call the broker, you had to set a
In the platform-specific page renderer code for Android, you set the
Then, include the parameters in the acquire token call:
|
In MSAL.NET, broker support is enabled on a per-PublicClientApplication basis.
Use the
Then, in the AcquireToken call:
|
Step 2: Set an Activity
In ADAL.NET, you passed in an activity (usually the MainActivity) as part of the PlatformParameters as shown in Step 1: Enable the broker.
MSAL.NET also uses an activity, but it's not required in regular Android usage without a broker. To use the broker, set the activity to send and receive responses from broker.
Current ADAL code: | MSAL counterpart: |
The activity is passed into the PlatformParameters in the Android-specific platform.
|
In MSAL.NET, do two things to set the activity for Android:
For example: In App.cs:
In MainActivity.cs:
In the AcquireToken call:
|
Next steps
For more information about Android-specific considerations when using MSAL.NET with Xamarin, see Configuration requirements and troubleshooting tips for Xamarin Android with MSAL.NET.
Feedback
Submit and view feedback for