AzureAD / microsoft-authentication-library-for-android

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

How to cancel acquireTokenWithDeviceCode ? #2116

Open DumTiDum opened 4 months ago

DumTiDum commented 4 months ago

Describe the bug I have an android-app, works with device-authentication-flow (and browser-authentication-flow). No issues, after the user logs in, I receive a token and can access my backend.

Once the user clicks log-in-via-device, I call acquireTokenWithDeviceCode. My app then shows a QR code, with the url and device-code. MSAL starts "pinging" some backend to receive confirmation that the user has logged in. And this "pinging" continues until the user does.

However the user could choose not to log in at all (in my app, he can press back).

How do I tell MSAL to cancel the device-authentication-flow, I don't want it to keep "pinging" the backend for confirmation that the user has logged in on another device.

Expected behavior There should be some interface to cancel the acquireTokenWithDeviceCode call. (It seems to be present on dotnet with a CancellationToken)

Actual Behavior There is no way to stop the acquireTokenWithDeviceCode-flow other than waiting for the timeout to happen.

negoe commented 3 months ago

hi @DumTiDum, Based on my discussion with the eng team, this is an expected behavior. We took a note of your suggested enhancement and will evaluate on our side. Thanks.

DumTiDum commented 3 months ago

Thanks, I hope it will be added soon.