microsoft-authentication-library-for-android icon indicating copy to clipboard operation
microsoft-authentication-library-for-android copied to clipboard

Interface is terrible! You should never use interfaces to inter-activity comunnication

Open SelvinPL opened this issue 5 months ago • 0 comments

In the example you are using AcquireTokenFragment it has acquireTokenCallback which is passed MsalWrapper which wrapps it with AuthenticationCallback

This is very bad code practice in android development - you are leaking fragment which MAY BE DEAD after code from this library (MAY AND WILL BE DEAD - if you enable "Don't keep activities" - and callback will be called on not atached dead fragment/activity)

Proper flow should be using Activity/Fragment.startActivityForResult/registerForActivityResult for IPublicClientApplication.acquireToken and ISingleAccountPublicClientApplication.signIn (and other functions which starts new activity)

It is ok for acquireTokenSilent to use callback since it doesn't start new activity

SelvinPL avatar Jul 10 '25 13:07 SelvinPL