Handle null intent in SetAuthenticationContinuationEventArgs (MSAL 2.1.0)
See original GitHub issueIs your feature request related to a problem? Please describe. SetAuthenticationContinuationEventArgs is the method used in when implementing MSAL for Xamarin Andorid, which handles the return from an interactive sign-in. It takes three arguments, requestCode (int), resultCode (Result) and data (Intent).
I am working with Xamarin.Forms and experiencing an issue on Android where the user triggers interactive sign-in (PublicClientApplication.AcquireTokenAsync), taps the home button, then launches the app again from the apps menu (rather than resuming from the overview). This results in the Intent being null and thus SetAuthenticationContinuationEventArgs fails.
Consider the example provided in the wiki:
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(requestCode, resultCode, data);
}
Following the described steps, data
will be null and, if unhandled, the app will crash.
Describe the solution you’d like
It would be good to have MSAL throw an MsalException
(or variant) so that I can handle this scenario gracefully within my sign in logic flow.
Describe alternatives you’ve considered Right now I am checking for a null intent within MainActivity.OnActivityResult and simply not calling SetAuthenticationContinuationEventArgs.
Additional context Steps to reproduce the scenario:
- Launch app and start interactive signin (where the browser is shown)
- Tap the device home button
- Open the apps menu and open the app from the menu
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:26 (8 by maintainers)
Top GitHub Comments
@bgavrilMS - any update on this one? I too am seeing these errors in App Center and Play Console.
Won’t fix Xamarin issue. Please reopen if it happens on Maui.