AzureAD / microsoft-authentication-library-for-android

Microsoft Authentication Library (MSAL) for Android
http://aka.ms/aadv2
MIT License
214 stars 125 forks source link

Urgent: No account saved after acquireTokenWithDeviceCode #1481

Closed parnesen closed 2 years ago

parnesen commented 3 years ago

Describe the bug This bug is affecting live users of AltSpaceVR, a Microsoft product.

To login on an Oculus Quest device, we first do a SingleAccountPublicClientApplication.acquireTokenWithDeviceCode for the user.read scope. Since we haven't gotten to 1st party status yet, this allows new users to grant permission for us to access their account, and also implicitly grants access to our own app-id.

once we've completed this flow successfully, we wait 1 second and then attempt an acquireTokenSilent for our own app's scope.

However the second call fails with: There is no signed in account.

Smartphone (please complete the following information):

Expected behavior I believe the account should be saved once acquireTokenWithDeviceCode succeeds, and then acquireTokenSilent should succeed thereafter.

Actual Behavior acquireTokenWithDeviceCode succeeds, but acquireTokenSilent then fails with the error message: There is no signed in account.

AdamBJohnsonx commented 3 years ago

Do you have a selection of logs from the device seeing the failure, or a correlation Id from the requests that are not succeeding?

parnesen commented 3 years ago

Adam Johnson helped me out on this. It looks like there's a bug where msal isn't saving the account after acquireTokenWithDeviceCode succeeds. This can be worked around by calling getCurrentAccount after acquireTokenWithDeviceCode completes, since getCurrentAccount has the side effect of saving the current account.

This is a pretty bad bug that I can easily imagine others getting tripped up on, so I recommend it be given some priority.

AdamBJohnsonx commented 3 years ago

https://identitydivision.visualstudio.com/Engineering/_workitems/edit/1509622

eusebiu commented 2 years ago

I am interested in calling MSAL for android from an Unity app. How do you call MSAL from AltSpaceVR running on Quest? Is there a separate wrapper or you invoke it directly?