Open thecrazyonestherebels opened 11 months ago
Why are you calling AcquireTokenInteractive
so often? After the first call, there will be a refresh token in the cache, and AcquireTokenSilent
will work, even if you call it for other resources.
I recommend you move away from the system browser and use WAM, see https:\aka.ms\msal-net-wam - this will solve the problem on Windows at least. Does the issue happen on Mac too?
This is a minimal reproducible sample to showcase the issue, AcquireTokenInteractive
is not necessarily called frequently, in actual use case this can be minutes / hours away in calls.
After the first call, there will be a refresh token in the cache, and
AcquireTokenSilent
will work, even if you call it for other resources.
The intention is not to refresh the token but ask it anew, as if application was locked and then unlock scenario happens and we want to ask the user to enter his credential again
I recommend you move away from the system browser and use WAM, see https:\aka.ms\msal-net-wam - this will solve the problem on Windows at least.
I am not sure WAM fits all my use cases, yet still the bug exists for external browser scenario, thus is there any chance to fix it or does external browser support is to be removed?
Does the issue happen on Mac too?
I have no access to Mac to check
Yes, we are moving away from "system browser" on desktop operating systems. Embedded browsers offer a slightly better user experience and the broker (which also uses an embedded browser) offers improved security. We could take a contribution on this one though.
Also, just calling AqcuireTokenIntreactive is not a strong way to enforce the "app lock". A malitious app could make pose as your app but make use of the refresh token. Have you considered https://learn.microsoft.com/en-us/entra/identity/conditional-access/howto-conditional-access-session-lifetime
Library version used
4.58
.NET version
4.6.2
Scenario
PublicClient - desktop app
Is this a new or an existing app?
None
Issue description and reproduction steps
When following steps are executed, MSAL throws error described below:
Relevant code snippets
Expected behavior
MSAL library should not throw an error in this case.
Identity provider
Microsoft Entra ID (Work and School accounts and Personal Microsoft accounts)
Regression
No response
Solution and workarounds
Issue happens highly intermittently ( 1 of 15 tries ) if
applicationBuilder.WithRedirectUri("http://localhost");
is provided as redirect URL, if stable port is used, as :applicationBuilder.WithRedirectUri("http://localhost:7890");
the issue will happen at least 1 of 2 times