question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Handle null intent in SetAuthenticationContinuationEventArgs (MSAL 2.1.0)

See original GitHub issue

Is 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:

  1. Launch app and start interactive signin (where the browser is shown)
  2. Tap the device home button
  3. Open the apps menu and open the app from the menu

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:26 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
WilliamWatterson86commented, Feb 18, 2019

@bgavrilMS - any update on this one? I too am seeing these errors in App Center and Play Console.

0reactions
bgavrilMScommented, Dec 22, 2022

Won’t fix Xamarin issue. Please reopen if it happens on Maui.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Leveraging the broker on iOS and Android
Step Three: Update AppDelegate to handle the callback. When MSAL.NET calls the broker, the broker will, in turn, call back to your application...
Read more >
msal.js 2.0 tokenResponse null after loginRedirect
I am developing an Angular 10 app that utilizes Azure B2C for policy and user management. I set up my app registration in...
Read more >
Xamarin Android code configuration and troubleshooting ...
SetAuthenticationContinuationEventArgs () method to return control to MSAL at the end of the interactive portion of the authentication flow.
Read more >
Use brokers with Xamarin iOS & Android - Microsoft Entra
Learn how to setup Xamarin iOS applications that can use the Microsoft Authenticator and the Microsoft Authentication Library for .NET (MSAL ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found